Skip to content

PAINTROID-761-2: Reconstruct Legacy Command Models from Binary Stream#167

Open
Amit-Matth wants to merge 2 commits into
Catrobat:developfrom
Amit-Matth:feature/paintroid-761-model-parser
Open

PAINTROID-761-2: Reconstruct Legacy Command Models from Binary Stream#167
Amit-Matth wants to merge 2 commits into
Catrobat:developfrom
Amit-Matth:feature/paintroid-761-model-parser

Conversation

@Amit-Matth

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

Copy link
Copy Markdown
Contributor

This Pull Request is the second step of our 4-stage plan to add backward compatibility for legacy .catrobat files. It registers sequential native class IDs and reconstructs raw command models (like CommandManagerModel and ColorHistory) from the Kryo binary stream.

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

  • Sequential Native Class Registration (KryoClassRegistry): Mapped sequential native Paintroid class IDs (from ID 9 to 55) in Dart, resolving registered classes and dynamic references on the wire with proper Kryo ID offsets.
  • Custom Deserializers for Legacy Helper Structures: Added custom binary deserializers under lib/core/backward_compatibility/legacy_deserializers.dart to decode standard helper structures (Paint, ColorHistory, Point, PointF, RectF, FloatArray, StringArray).
  • Path Action Deserialization (SerializablePath): Implemented dynamic deserialization for legacy SerializablePath and all its individual path actions (Move, Line, Quad, Cube, and Rewind).
  • Legacy Command Model Parsing (LegacyCommandManagerModel): Completed raw deserialization of the root CommandManagerModel structure, including decoding for all 14 legacy command types (such as SetDimensionCommand, PathCommand, layer state operations, flip/rotate/crop/resize commands).
  • Comprehensive Registry & Parser Unit Testing: Added a complete suite of unit tests under test/unit/serialization/kryo_class_registry_test.dart to verify the exact reconstruction of all custom objects and command sequences. All tests are passing locally.
  • Isolated Implementation: Maintained strict directory separation 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 (Completed - Foundational Binary Reader): The low-level KryoReader to parse bytes into basic Dart datatypes (ints, strings, doubles).
  2. Stage 2 (This PR - 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

@Amit-Matth Amit-Matth marked this pull request as draft June 4, 2026 16:23
@Amit-Matth Amit-Matth force-pushed the feature/paintroid-761-model-parser branch from c648854 to 060b61b Compare June 10, 2026 09:22
@Amit-Matth Amit-Matth force-pushed the feature/paintroid-761-model-parser branch from 060b61b to a397514 Compare June 10, 2026 09:43
@Amit-Matth Amit-Matth marked this pull request as ready for review June 10, 2026 09:57
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