Skip to content

[iOS] Fix concurrent modification crash#4008

Open
m-bert wants to merge 1 commit intomainfrom
@mbert/long-press-crash
Open

[iOS] Fix concurrent modification crash#4008
m-bert wants to merge 1 commit intomainfrom
@mbert/long-press-crash

Conversation

@m-bert
Copy link
Contributor

@m-bert m-bert commented Feb 27, 2026

Description

In reattachHandlersIfNeeded method we are iterating over handlers contained in registry. The following crash was reported:

NSDictionary was mutated while being enumerated

In this PR I've changed the loop to iterate over copy - this should fix this issue.

Note

For now we have no consistent reproduction. I'm also not sure where this concurrent modification takes place. It seems to be indirect, as previous keyframe in provided stack trace was flushOperations.

Test plan

Tested on the example code from #3964

Copilot AI review requested due to automatic review settings February 27, 2026 18:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a concurrent modification crash in the iOS gesture handler implementation. The crash occurred when reattachHandlersIfNeeded iterated over the handlers registry while the collection was being modified, causing a "NSDictionary was mutated while being enumerated" error. This method was introduced in PR #3964 to handle view recycling on the new architecture when parent views have display: none.

Changes:

  • Create a defensive copy of the handlers collection before iterating in reattachHandlersIfNeeded
  • Add a comment explaining the defensive copy to prevent concurrent modification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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