fix(main-editor): ignore spurious scale-end on mid-gesture pointer change (#850) - #851
Merged
Merged
Conversation
…ange (#850) Flutter's ScaleGestureRecognizer fires a spurious onScaleEnd (followed by a fresh onScaleStart) whenever the active pointer count changes mid-gesture, e.g. when a third finger touches the screen while two fingers are rotating a layer. _onScaleEnd then ran its full interaction teardown (replacing the last screenshot, mutating the history stack, clearing the selection), which corrupted the history/screenshot stack and, on iOS, crashed the editor with a `_dependents.isEmpty` framework assertion. - _onScaleEnd now returns early when details.pointerCount > 0 (reconfiguration rather than a real end); the interactive viewer still receives the event so its start/end pairing stays balanced. - _onScaleStart no longer adds a second history entry when a transform is already in progress. Adds a deterministic multi-pointer widget test reproducing the crash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #850 — editor freezes / crashes after a three-finger gesture while rotating an emoji layer (reported on iOS).
Flutter's
ScaleGestureRecognizerfires a spuriousonScaleEnd(immediately followed by a freshonScaleStart) whenever the active pointer count changes mid-gesture — e.g. when a third finger touches the screen while two fingers are still rotating a layer (verified ingestures/scale.dart_reconfigure, line 717)._onScaleEndthen ran its full interaction teardown (replacing the last screenshot, mutating the history stack, clearing the selection) even though the gesture was only being reconfigured, not ended. Two symptoms of the same root cause:assert(_dependents.isEmpty)inInheritedElement.debugDeactivated()→ red screen + frozen editor on iOS.RangeErrorfromscreenshots.removeLast().Fix
_onScaleEndreturns early whendetails.pointerCount > 0(a reconfiguration rather than a real end). The interactive viewer still receives the event so its own start/end pairing stays balanced._onScaleStartno longer adds a second history entry when a transform is already in progress (!isLayerBeingTransformed).Test
Adds
test/features/main_editor/multitouch_third_finger_test.dart, a deterministic multi-pointer widget test that drives the exact sequence (two-finger rotate on a selected emoji layer, then a third pointer down). It reproduces the crash before the fix and passes after — no physical device needed.flutter analyze: clean