Repository navigation
Commit 783675c
authored
Guard ReactEditText.onTouchEvent against framework IndexOutOfBoundsException
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
Pull Request resolved: #602861 parent 9d6a249 commit 783675c
1 file changed
Lines changed: 8 additions & 1 deletion
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
365 | 372 | | |
366 | 373 | | |
367 | 374 | | |
| |||
0 commit comments