fix: drawing tools desync in release builds (ghost tools, broken symbol persistence)#478
fix: drawing tools desync in release builds (ghost tools, broken symbol persistence)#478ahrar-deriv wants to merge 4 commits into
Conversation
…ol persistence) Release-mode timing exposed several sync failures between the drawing tools repository, the interactive layer state machine, and the painted layer: - updateStateTo could await a TickerFuture that never completes when a keyed remount disposes the AnimationController mid-animation, leaving the state machine stuck; awaited animations now use .orCancel with mounted guards, and a sequence guard drops superseded transitions. - The add flow selected the preview drawing instance without the persisted configId, breaking later edits/deletes; the repo-backed config is now bound to the selected instance and reconciliation unifies map/selected instances sharing the same id. - The gesture handler painted and hit-tested a snapshot drawings list that could go stale when a rebuild failed to propagate (bottom-sheet "clear all"); it now reads the reconciled map live and repaints via a drawings-changed notifier independent of rebuild delivery. Adds debug-only [chart-diag] logging and regression tests covering remount-cancelled transitions, superseded transitions, instance unification, and clear-all repaint.
Reviewer's GuideFixes multiple release-only desync issues between the drawing tools repository, interactive layer state machine, and painted layer by making state transitions robust to animation cancellation, reconciling the live drawings map with the repo/state machine on every build, wiring gesture handler painting/hit-testing to that live map, correctly binding persisted configs to selected drawings, and adding diagnostics/tests plus minor chart remounting and intl dependency fixes. Sequence diagram for drawing tool add and selection syncsequenceDiagram
actor User
participant ILBehaviour as InteractiveLayerBehaviour
participant AddingState as InteractiveAddingToolState
participant ILayer as InteractiveLayer
participant Repo as AddOnsRepository
participant LayerState as _InteractiveLayerState
participant Handler as _InteractiveLayerGestureHandlerState
User->>ILBehaviour: startAddingTool
ILBehaviour->>AddingState: enter (InteractiveAddingToolState)
User->>AddingState: onPanEnd
AddingState->>ILayer: clearAddingDrawing
AddingState->>ILayer: addDrawing(getUpdatedConfig)
ILayer-->>AddingState: DrawingToolConfig addedConfig
AddingState->>AddingState: _drawingPreview.interactableDrawing.config = addedConfig
ILayer->>Repo: add(addedConfig)
Repo-->>LayerState: notifyListeners
LayerState->>LayerState: syncDrawingsWithConfigs
LayerState->>LayerState: _reconcileDrawings
LayerState->>LayerState: _notifyDrawingsChanged
LayerState-->>Handler: drawingsChanged.notify
Handler->>Handler: _checkIsAToolAdded
Handler->>ILBehaviour: aNewToolsIsAdded(drawing)
AddingState->>ILBehaviour: updateStateTo(InteractiveSelectedToolState,
note right of ILBehaviour: waitForAnimation: false
ILBehaviour->>ILayer: onUpdate()
ILayer-->>User: selected tool is repo-backed and painted
Sequence diagram for robust state transitions with animation cancellationsequenceDiagram
participant Caller
participant ILBehaviour as InteractiveLayerBehaviour
participant Handler as _InteractiveLayerGestureHandlerState
participant AnimCtrl as AnimationController
Caller->>ILBehaviour: updateStateTo(newState,
note right of ILBehaviour: waitForAnimation: true
ILBehaviour->>ILBehaviour: _stateTransitionSeq++ (seq1)
ILBehaviour->>Handler: animateStateChange(direction, animate)
Handler->>Handler: _runAnimation(direction, animate)
alt forward animation
Handler->>AnimCtrl: reset
Handler->>AnimCtrl: forward().orCancel
else reverse animation
Handler->>AnimCtrl: reverse(from: 1).orCancel
end
alt handler disposed during animation
AnimCtrl--xHandler: TickerCanceled
Handler->>Handler: catch TickerCanceled
Handler-->>ILBehaviour: animation completes logically
end
ILBehaviour->>ILBehaviour: check seq1 == _stateTransitionSeq
alt superseded by newer transition
ILBehaviour->>ILBehaviour: drop newState assignment
else still current
ILBehaviour->>ILBehaviour: _controller.currentState = newState
ILBehaviour->>Handler: onUpdate()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Filesexample/pubspec.yaml
|
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @ahrar-deriv's task —— View job PR Review: Drawing Tools Desync FixOverviewThis PR addresses critical synchronization issues between the drawing tools repository, interactive layer state machine, and painted layer that manifest primarily in release builds. The fixes are well-architected and address real timing/lifecycle issues. Priority IssuesHIGH PRIORITY1. Potential Memory Leak in
|
This PR contains the following changes:
Release-mode timing exposed several sync failures between the drawing
tools repository, the interactive layer state machine, and the painted
layer:
keyed remount disposes the AnimationController mid-animation, leaving
the state machine stuck; awaited animations now use .orCancel with
mounted guards, and a sequence guard drops superseded transitions.
persisted configId, breaking later edits/deletes; the repo-backed
config is now bound to the selected instance and reconciliation
unifies map/selected instances sharing the same id.
that could go stale when a rebuild failed to propagate (bottom-sheet
"clear all"); it now reads the reconciled map live and repaints via a
drawings-changed notifier independent of rebuild delivery.
Adds debug-only [chart-diag] logging and regression tests covering
remount-cancelled transitions, superseded transitions, instance
unification, and clear-all repaint.
Developers Note (Optional)
Pre-launch Checklist (For PR creator)
As a creator of this PR:
Reviewers
@behnam-deriv
Pre-launch Checklist (For Reviewers)
As a reviewer I ensure that:
Pre-launch Checklist (For QA)
Pre-launch Checklist (For Maintainer)
Summary by Sourcery
Improve synchronization between drawing tools repository, interactive layer state machine, and painted layer to prevent ghost tools and stuck states in release builds.
Bug Fixes:
Enhancements:
Build:
Tests: