Skip to content

Guard ReactEditText.onTouchEvent against framework IndexOutOfBoundsException - #60286

Merged
meta-codesync[bot] merged 1 commit into
react:mainfrom
cipolleschi:export-D134404457
Nov 25, 2026
Merged

meta-codesync[bot] merged 1 commit into
react:mainfrom
cipolleschi:export-D134404457

Conversation

@cipolleschi

Copy link
Copy Markdown
Contributor

Summary:
The Android framework Editor can throw IndexOutOfBoundsException from TextView.onTouchEvent while a cursor or selection handle is being dragged and the text or layout shrinks underneath it (Editor.performCursorDrag -> positionCursorDuringDrag -> DynamicLayout.getLineStart on a line that no longer exists). ReactEditText.onTouchEvent only delegates to super, so the exception crashes the app.

Catch the exception around super.onTouchEvent, report it as a soft exception, and consume the event. This matches the existing guard for the same class of framework exception in updateCachedSpannable.

Changelog:
[Android][Fixed] - Prevent crash in TextInput when the framework throws IndexOutOfBoundsException while dragging the cursor handle

Differential Revision: D134404457

…ception

Summary:
The Android framework `Editor` can throw `IndexOutOfBoundsException` from `TextView.onTouchEvent` while a cursor or selection handle is being dragged and the text or layout shrinks underneath it (`Editor.performCursorDrag` -> `positionCursorDuringDrag` -> `DynamicLayout.getLineStart` on a line that no longer exists). `ReactEditText.onTouchEvent` only delegates to `super`, so the exception crashes the app.

Catch the exception around `super.onTouchEvent`, report it as a soft exception, and consume the event. This matches the existing guard for the same class of framework exception in `updateCachedSpannable`.

Changelog:
[Android][Fixed] - Prevent crash in `TextInput` when the framework throws `IndexOutOfBoundsException` while dragging the cursor handle

Differential Revision: D134404457
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 25, 2026
@meta-codesync

meta-codesync Bot commented Nov 25, 2026

Copy link
Copy Markdown

@cipolleschi has exported this pull request. If you are a Meta employee, you can view the originating Diff in D134404457.

@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 778d7c4aabc0.

ios: no capture

@meta-codesync
meta-codesync Bot merged commit 783675c into react:main Nov 25, 2026
65 checks passed
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @cipolleschi in 783675c

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants