fix: prevent mobile auto-scroll feedback loops - #1216
Open
ContextFound wants to merge 4 commits into
Open
Conversation
EdgeDraggingAutoScroller._scroll re-invokes itself via `await _scroll()` while `_scrolling` is true. position.moveTo can complete synchronously when the scrollable cannot advance (already at an extent, zero scroll range, or pinned), turning the self-recursion into a tight microtask loop that pins the platform/UI thread with no frames — an ANR on mobile when leaving a table cell (symbolicated: _microtaskLoop -> Future completion -> EdgeDraggingAutoScroller._scroll). Stop when moveTo makes no forward progress, which bounds the loop.
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Fixes #1215.
This fixes a mobile editor auto-scroll feedback loop that remained after the table row-height relayout fix in #1214. On a physical Android device, table focus/defocus could still ANR the app; after moving repeat work off microtasks, the remaining issue surfaced as visible content vibration during table selection.
Root cause
EdgeDraggingAutoScroller._scrollrecursively awaited itself while_scrollingwas true.ScrollPosition.moveTocan complete synchronously when the scroll position cannot make meaningful progress, so the recursion can become a tight microtask chain that starves frames/input.Separately, mobile selection changes were starting repeating auto-scroll for ordinary caret/table focus updates. Those updates need at most a one-shot keep-visible nudge; continuous repeat should be reserved for active drag selection.
Fix
SchedulerBinding.scheduleFrameCallbackinstead of recursiveawait _scroll().repeatflag to the auto-scroll service.repeat: trueonly for mobile drag modes (leftSelectionHandle,rightSelectionHandle,cursor); ordinary selection/caret updates use one-shot auto-scroll.Verification
dart format --set-exit-if-changedon touched Dart filesflutter analyzeMade with Cursor