Fix IllegalArgumentException crash in ScrollView.onTouchEvent on Android#56926
Open
tomekzaw wants to merge 1 commit into
Open
Fix IllegalArgumentException crash in ScrollView.onTouchEvent on Android#56926tomekzaw wants to merge 1 commit into
IllegalArgumentException crash in ScrollView.onTouchEvent on Android#56926tomekzaw wants to merge 1 commit into
Conversation
The same IllegalArgumentException thrown by Android's framework ScrollView when its tracked active pointer becomes stale is already caught in onInterceptTouchEvent in all three Android ScrollView variants (ReactScrollView, ReactHorizontalScrollView, ReactNestedScrollView) but not in onTouchEvent. Mirror the existing workaround into onTouchEvent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D106042303. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary:
Android's framework
ScrollViewcan throwIllegalArgumentException: pointerIndex out of rangefromMotionEvent.getY()inScrollView.onTouchEventwhen the view's tracked active pointer becomes stale after a multi-touchACTION_POINTER_UP.This is a known Android framework bug
The same exception in sibling widgets (
SwipeRefreshLayout,ViewPager) has been reported and worked around withtry/catchsince at least 2014 — see the Stack Overflow question already linked in the existing in-tree comment, and Google's AOSP Issue #36987494. React Native added the same workaround toReactScrollView.onInterceptTouchEventin 67c3ad4 (2018-02-16, originally proposed in #12085 and #13166), with the comment:The bug is still active on current Android releases — the production stack trace below is from Android 15 (SDK 35) on a Motorola moto g15, May 2026.
The gap this PR closes
ReactScrollView,ReactHorizontalScrollViewandReactNestedScrollViewalready catch thisIllegalArgumentExceptioninonInterceptTouchEvent, but the same catch is missing fromonTouchEventin all three classes, even thoughsuper.onTouchEvent(ev)reaches the same framework code path that can throw. This PR mirrors the existing in-file workaround intoonTouchEvent.Production stack trace (Sentry, May 2026)
Device: Motorola moto g15
OS: Android 15 (SDK 35, build
VVTA35.51-153)App stack: React Native 0.85.3 with react-native-gesture-handler
The
MotionEventdump pinpoints the trigger: a two-fingerACTION_POINTER_UP(1)where the frameworkScrollView's trackedmActivePointerIdis stale, sofindPointerIndex(...)returns-1andgetY(-1)throws from native code.Closes #30320
Closes #29642
Both issues were auto-closed by the stale bot without a fix shipping, despite multiple confirmed reproductions over 4+ years.
Changelog:
[ANDROID] [FIXED] - Catch IllegalArgumentException in ScrollView.onTouchEvent to prevent crashes from a known Android framework multi-touch bug
Test Plan:
Can't really reproduce locally — the crash happens very infrequently in production. The Sentry stack trace above is what triggered this PR.