fix: Crash on Android 10 due to pointerIndex out of range in ReactScrollView with react-native-gesture-handler #3642
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.
WHAT IS THE DRIVING SCENARIO?
This crash, Fatal Exception: java.lang.IllegalArgumentException with message pointerIndex out of range , occurring in com.facebook.react.views.scroll.ReactScrollView.onTouchEvent , indicates a problem with how touch events are being handled in the Android native layer by the ReactScrollView component.
Given the information about react-native-gesture-handler and the forum post, the cause is an integration issue between ReactScrollView and react-native-gesture-handler , where intercepting the latter's event disrupts the former's expectations regarding pointer indices.
HOW TO REPRODUCE?
Use an Android 10 device.
Access a screen with ReactScrollView active.
End up with an input field activated with the keyboard showing. Repeatedly scrolling
The app may crash and close unexpectedly.
WHAT WAS DONE IN THIS PR?
Applied a mitigation patch related to the pointerIndex out of range issue, inspired by discussions and solutions in the react-native-gesture-handler repository
Ensured compatibility between ReactScrollView and react-native-gesture-handler to avoid conflicts in touch events.
Added additional protections in native handlers to prevent invalid pointer exceptions.
HOW TO TEST LOCALLY?
Run a production app because the issue doesn't occur with a debug app.
Install the app on a device with Android 10.
Keep an input field activated with the keyboard showing.
Keep scrolling up and down until it crashes.