Skip to content

[Android] Fix ConcurrentModificationException in GestureHandlerOrchestrator#4274

Draft
kosmydel wants to merge 4 commits into
software-mansion:mainfrom
discord:kosmydel/orchestrator-concurrency-fix
Draft

[Android] Fix ConcurrentModificationException in GestureHandlerOrchestrator#4274
kosmydel wants to merge 4 commits into
software-mansion:mainfrom
discord:kosmydel/orchestrator-concurrency-fix

Conversation

@kosmydel

@kosmydel kosmydel commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes a ConcurrentModificationException in GestureHandlerOrchestrator when delivering and cancelling events. Event delivery now iterates over local snapshots of gestureHandlers instead of a shared preparedHandlers field and the live asReversed() view, both of which could be mutated mid-iteration during re-entrant state updates.

Credit to @SudoPlz for the original fix. This PR upstreams it into the main repository

Note

We don't have a reliable repro for this. It surfaced in our Sentry logs as a crash, and the fix is based on inspection of the orchestrator's re-entrancy behavior.

Test steps

  1. Build and run the Android example app (apps/basic-example, yarn android).
  2. Exercise screens with multiple interacting gesture handlers (e.g. nested gestures, swipeables) and confirm no regressions in gesture behavior.

Made with Cursor

…trator

Use local snapshots of `gestureHandlers` when delivering and cancelling
events instead of a shared `preparedHandlers` field and the live
`asReversed()` view, both of which could throw during re-entrant state
updates.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings June 18, 2026 12:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

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.

2 participants