Fix race condition between the orchestrator and the registry #1684
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.
Description
Should fix #1639
The
IndexOutOfBoundsExceptionwas thrown at line 387:react-native-gesture-handler/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java
Lines 383 to 388 in 0343428
So the
handlerscollection must have been modified in other place and the registry is the only class that modifies it. My guess is that the handler was dropped or removed from view and relevant method was called (asynchronously)causing the list to be modified while it was being iterated over. This PR locks the list while it's being modified or iterated over.
Test plan
I couldn't reproduce the issue, but I tested the changes on the Example app and it works correctly.