Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfBoundsException: charAt: X >= length X #20481

Closed
sentry-io bot opened this issue Mar 15, 2024 · 5 comments · Fixed by wordpress-mobile/AztecEditor-Android#1078, wordpress-mobile/gutenberg-mobile#6765 or #20518
Assignees
Labels
Milestone

Comments

@sentry-io
Copy link

sentry-io bot commented Mar 15, 2024

Sentry Issue: JETPACK-ANDROID-87V

Exception java.lang.IndexOutOfBoundsException:
    at android.text.SpannableStringBuilder.charAt (SpannableStringBuilder.java:126)
    at android.text.CharSequenceCharacterIterator.current (CharSequenceCharacterIterator.java:58)
    at android.text.CharSequenceCharacterIterator.setIndex (CharSequenceCharacterIterator.java:83)
    at android.icu.text.RuleBasedBreakIterator.CISetIndex32 (RuleBasedBreakIterator.java:1055)
    at android.icu.text.RuleBasedBreakIterator.isBoundary (RuleBasedBreakIterator.java:549)
    at android.text.method.WordIterator.isBoundary (WordIterator.java:102)
    at android.widget.Editor$SelectionHandleView.positionAtCursorOffset (Editor.java:7885)
    at android.widget.Editor$HandleView.invalidate (Editor.java:5998)
    at android.widget.Editor$SelectionModifierCursorController.invalidateHandles (Editor.java:8845)
    at android.widget.Editor.invalidateHandlesAndActionMode (Editor.java:2527)
    at android.widget.TextView.spanChange (TextView.java:12117)
    at android.widget.TextView$ChangeWatcher.onSpanChanged (TextView.java:15308)
    at android.text.SpannableStringBuilder.sendSpanChanged (SpannableStringBuilder.java:1321)
    at android.text.SpannableStringBuilder.setSpan (SpannableStringBuilder.java:766)
    at android.text.SpannableStringBuilder.setSpan (SpannableStringBuilder.java:690)
    at androidx.emoji2.text.SpannableBuilder.setSpan (SpannableBuilder.java:135)
    at org.wordpress.aztec.watchers.SuggestionWatcher.reapplyCarriedOverInlineSpans (SuggestionWatcher.kt:146)
    at org.wordpress.aztec.watchers.SuggestionWatcher.onTextChanged (SuggestionWatcher.kt:82)
    at org.wordpress.mobile.ReactNativeAztec.ReactAztecText$TextWatcherDelegator.onTextChanged (ReactAztecText.java:624)
@dangermattic
Copy link
Collaborator

dangermattic commented Mar 15, 2024

Thanks for reporting! 👍

Copy link
Author

sentry-io bot commented Mar 15, 2024

Sentry Issue: WORDPRESS-ANDROID-2J4P

@antonis antonis changed the title IndexOutOfBoundsException: charAt: 129 >= length 129 IndexOutOfBoundsException: charAt: X >= length Y Mar 15, 2024
@antonis antonis added Posting/Editing [Type] Crash Aztec Gutenberg Editing and display of Gutenberg blocks. labels Mar 15, 2024
@antonis
Copy link
Member

antonis commented Mar 15, 2024

The crash occurs on this line of the Aztec editor.

@antonis
Copy link
Member

antonis commented Mar 15, 2024

I merged all the relevant Sentry issues which were reported separately due to the different index and length after noticing the issue trending high on app vitals.
Screenshot 2024-03-15 at 2 44 49 PM

@antonis antonis changed the title IndexOutOfBoundsException: charAt: X >= length Y IndexOutOfBoundsException: charAt: X >= length X Mar 15, 2024
@antonis
Copy link
Member

antonis commented Mar 21, 2024

The crash occurs on this line of the Aztec editor.

The exception is thrown from the SpannableStringBuilder when the requested character position >= length and the logs show that in all cases it is thrown when position == length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment