Skip to content

fix(mobile): prevent recursive scroll corrections on ios - #936

Merged
nixuuu merged 1 commit into
devfrom
fix/background-thread-sync-crash
Nov 17, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/background-thread-sync-crash

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Opening or dismissing the iOS keyboard can synchronously re-enter the scroll handler while useFollowingList is correcting native anchor displacement. If UIKit reports a clamped offset, the nested handler dispatches another scrollTo before the first command returns, overflowing the UI-runtime stack. The reproduced iOS error contains hundreds of repeated track → scrollTo → onScroll frames.

Guard automatic corrections for the lifetime of the native command. Nested events retain the actual native offset and following intent without dispatching another correction. Increment the existing correction revision before dispatch so composer gesture tracking discards corrected events; release the guard in finally. Update the mobile behavior documentation.

Fixes: #909

Validation:

  • Mobile TypeScript check, targeted oxlint and ESLint, formatting and diff checks passed.
  • Expo's iOS Babel transform successfully generated the edited worklets.
  • A scratch probe using the actual callback source reproduced stack overflow before the change (3,483 nested commands) and one command afterward. Checked clamped/successful feedback, reader scrolling, disclosure anchoring, cleanup after dispatch failure and subsequent corrections. This probe does not execute UIKit or a native worklet runtime; no probe artifacts are committed.
  • The reporter verified the fix on their physical iPhone and confirmed the application no longer crashes when reproducing the issue.
  • All 15 CI checks passed for commit 0672d9a.

Guard synchronous scrollTo feedback while keyboard insets change. Record native offsets without redispatching or dropping following intent, and invalidate composer gesture travel before correcting.

Fixes: #909
@nixuuu
nixuuu marked this pull request as ready for review November 17, 2026 18:12
@nixuuu
nixuuu merged commit 141b562 into dev Nov 17, 2026
16 checks passed
@nixuuu
nixuuu deleted the fix/background-thread-sync-crash branch November 17, 2026 18:12
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