Skip to content

PAINTROID-761: Implement foundational Kryo binary reader in Dart#165

Open
Amit-Matth wants to merge 1 commit into
Catrobat:developfrom
Amit-Matth:PAINTROID-761-kryo-reader
Open

PAINTROID-761: Implement foundational Kryo binary reader in Dart#165
Amit-Matth wants to merge 1 commit into
Catrobat:developfrom
Amit-Matth:PAINTROID-761-kryo-reader

Conversation

@Amit-Matth

@Amit-Matth Amit-Matth commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

This Pull Request is the first step of our 4-stage plan to add backward compatibility for legacy .catrobat files. It introduces the low-level binary reader in Dart to decode raw Kryo streams.

PAINTROID-761

Note: The comments in the code have been kept to make review of the binary format easier, and they will be removed once the PR has been reviewed.

New Features and Enhancements

  • Implemented Foundational Kryo Binary Reader (KryoReader): Created a high-performance binary reader under lib/core/backward_compatibility/kryo_reader.dart to decode primitive data types (integers, floats, doubles, booleans, characters).
  • Varint and Varlong Decoding: Added support for variable-length integers and longs used in Kryo serialization, including ZigZag decoding for signed compression.
  • Kryo String Protocol: Implemented full Kryo string specifications (handling null strings, empty strings, and UTF-8/ASCII bytes) including support for Kryo's custom ASCII-optimization flag.
  • Robust Unit Testing: Added comprehensive unit tests under test/unit/serialization/kryo_reader_test.dart to verify navigation, fixed primitives, varints, and optimized strings. All tests are passing locally.
  • Isolated Implementation: Kept all new code separated under lib/core/backward_compatibility/, ensuring zero impact on the existing codebase during review.

Backward Compatibility Roadmap

To make this feature easy to review and track, the work is organized into four sequential stages:

  1. Stage 1 (This PR - Foundational Binary Reader): The low-level KryoReader to parse bytes into basic Dart datatypes (ints, strings, doubles).
  2. Stage 2 (Registry & Model Parser): Setting up the class registry matching the native app's sequential registration IDs to reconstruct raw objects (like CommandManagerModel and ColorHistory).
  3. Stage 3 (Command Transformation): Converting those legacy Android commands (such as historical lines, shapes, and layer state changes) into their equivalent Flutter drawing commands.
  4. Stage 4 (UI Performance & Fallbacks): Running the decoding logic on background isolates to keep the UI smooth during large file loads, and adding fallback renderers for legacy tools not yet supported by Flutter.

Refactorings and Bug Fixes

  • None (New feature foundation).

Checklist

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Add the link to the ticket in Jira in the description of the PR
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines (Wiki)
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Add new information to the Wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant