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

TextInput hangs with Samsung keyboard's Grammarly integration #35590

Closed
Houguiram opened this issue Dec 7, 2022 · 107 comments
Closed

TextInput hangs with Samsung keyboard's Grammarly integration #35590

Houguiram opened this issue Dec 7, 2022 · 107 comments
Labels
API: Keyboard Component: TextInput Related to the TextInput component. Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Priority: High Resolution: Fixed A PR that fixes this issue has been merged.

Comments

@Houguiram
Copy link

Houguiram commented Dec 7, 2022

UPDATE: we have now released patch releases containing fixes for:


Description

There is an issue with React Native's TextInput component when using Samsung's keyboard with the Grammarly integration enabled. When typing a text that is longer than a few lines, the app often hangs and becomes unresponsive, leading to a high rate of ANRs and crashes.

This issue has already been documented here and here but I'm worried that the lack of a reliable reproducer as well as the noise due to other random freeze and crashes in Android (esp. with the new Android 13 update) is preventing those issues from gaining traction and becoming a high priority.

I am therefore creating this new issue focused solely on the impact of the Samsung keyboard's Grammarly integration on the TextInput component, with a reliable reproducer, as I believe that something can be done at the TextInput level to address it.

Here is everything we know so far:

  • Any React Native app that involves writing long text in a TextInput seem to be impacted.
  • The issue happens with the default Samsung keyboard with the Grammarly integration (aka "Suggest text corrections" aka "Writing assistant") enabled. This integration is now enabled by default with Samsung's new Android 13 and One UI 5.0 update, currently on a progressive rollout until the end of the year, increasing the impact of the issue. This issue can be reproduced on earlier versions of Android as well.
  • The issue does not happen when the Grammarly integration is disabled or when using a different keyboard like Gboard.
  • The issue happens sporadically when writing a paragraph of text, but it can be reliably reproduced by pasting a big wall of text (~1000 words), waiting for Grammarly to analyse it and display its green underlines, then typing.
  • The issue is a lot less impactful when using uncontrolled inputs rather than controlled inputs with a value prop. Switching to uncontrolled inputs decreased the amount of occurences of the issue in the field for us, but it's still happening a lot. More info here.
  • The issue can still be reproduced with uncontrolled inputs, but a lot more text need to be pasted and parsed by Grammarly before the issue happens reliably.
  • The vast majority of related ANRs recorded in the field are hanging on android.text.SpannableStringBuilder
  • Profiling and analysing the callstack shows a disproportionately long android.text.DynamicLayout.reflow when reproducing the issue, as well as a higher number of calls to android.text.SpannableStringBuilder.countSpans.

You'll find an example ANR stacktrace, recorded callstacks on different keyboards, and details of the callstacks in the toggles below.

ANR stacktrace

io.sentry.android.core.ApplicationNotResponding: Application Not Responding for at least 5000 ms.
    at java.lang.Class.isAssignableFrom(Class.java:590)
    at java.lang.Class.isInstance(Class.java:542)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:985)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:1005)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:1005)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:1005)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:1005)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpans(SpannableStringBuilder.java:894)
    at android.text.SpannableStringBuilder.getSpans(SpannableStringBuilder.java:863)
    at android.text.MeasuredParagraph.buildForStaticLayout(MeasuredParagraph.java:445)
    at android.text.PrecomputedText.createMeasuredParagraphs(PrecomputedText.java:505)
    at android.text.StaticLayout.generate(StaticLayout.java:717)
    at android.text.DynamicLayout.reflow(DynamicLayout.java:612)
    at android.text.DynamicLayout$ChangeWatcher.reflow(DynamicLayout.java:1091)
    at android.text.DynamicLayout$ChangeWatcher.onSpanChanged(DynamicLayout.java:1127)
    at android.text.SpannableStringBuilder.sendSpanChanged(SpannableStringBuilder.java:1321)
    at android.text.SpannableStringBuilder.sendToSpanWatchers(SpannableStringBuilder.java:665)
    at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:594)
    at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:232)
    at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:39)
    at android.text.method.BaseKeyListener.backspaceOrForwardDelete(BaseKeyListener.java:376)
    at android.text.method.BaseKeyListener.backspace(BaseKeyListener.java:71)
    at android.text.method.BaseKeyListener.onKeyDown(BaseKeyListener.java:485)
    at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:362)
    at com.facebook.react.views.textinput.c$b.onKeyDown(ReactEditText.java:1)
    at android.widget.TextView.doKeyDown(TextView.java:9503)
    at android.widget.TextView.onKeyDown(TextView.java:9275)
    at android.view.KeyEvent.dispatch(KeyEvent.java:3501)
    at android.view.View.dispatchKeyEvent(View.java:15384)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.widget.ScrollView.dispatchKeyEvent(ScrollView.java:738)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at g.d.o.y.dispatchKeyEvent(ReactRootView.java:4)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
    at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:1091)
    at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1958)
    at android.app.Activity.dispatchKeyEvent(Activity.java:4324)
    at androidx.core.app.f.superDispatchKeyEvent(ComponentActivity.java:1)
    at androidx.core.view.j.e(KeyEventDispatcher.java:2)
    at androidx.core.app.f.dispatchKeyEvent(ComponentActivity.java:3)
    at androidx.appcompat.app.d.dispatchKeyEvent(AppCompatActivity.java:4)
    at c.a.o.i.dispatchKeyEvent(WindowCallbackWrapper.java:1)
    at androidx.appcompat.app.g$o.dispatchKeyEvent(AppCompatDelegateImpl.java:2)
    at c.a.o.i.dispatchKeyEvent(WindowCallbackWrapper.java:1)
    at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:915)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:7870)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7678)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7027)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7084)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7050)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7248)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7058)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7305)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7031)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7084)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7050)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7058)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7031)
    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:10602)
    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:10490)
    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:10446)
    at android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl(ViewRootImpl.java:6642)
    at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:6517)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8772)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Profiling with callstacks

Samsung keyboard with controlled input

https://drive.google.com/file/d/1vecylVsRx5Hh-XRI4LfACXwO9DtOcO_h/view?usp=share_link

Untitled Untitled (1) Untitled (2)

Gboard with controlled input

https://drive.google.com/file/d/1avWBkD_NgDodccr3CW2flFX-AWpcfN3z/view?usp=share_link

Untitled (3) Untitled (4) Untitled (5)

Version

Latest version (0.70.6) but earlier ones as well

Output of npx react-native info

System:
    OS: macOS 13.0.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 91.58 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.10.0 - ~/.nvm/versions/node/v18.10.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.10.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.10.0/bin/npm
    Watchman: 2022.11.28.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: Dolphin 2021.3.1 Patch 1 Dolphin 2021.3.1 Patch 1
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.17 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0
    react-native: 0.70.6 => 0.70.6
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  • Use the linked Expo snack or theminimal-text-input-repro repo to get the app running on a Samsung device
  • Make sure that you are using the Samsung keyboard and that the Grammarly integration is enabled (it should underline in green mistakes when you write)
  • Paste a big wall of text (at least 1000 words) in the input in the app
  • Wait for Grammarly to process it and underline mistakes
  • Start typing, and pretty quickly the keyboard should slow down significantly, to the point of freezing
  • You can use the toggle at the top-right corner of the app to switch to an uncontrolled input to observe the difference it makes

For convenience, here is a wall of text you can copy to reproduce the issue. Try pasting it multiple times if pasting it once doesn't trigger the issue straight away.

Wall of text

Remain lively hardly needed at do by. Two you fat downs fanny three. True mr gone most at. Dare as name just when with it body. Travelling inquietude she increasing off impossible the. Cottage be noisier looking to we promise on. Disposal to kindness appetite diverted learning of on raptures. Betrayed any may returned now dashwood formerly. Balls way delay shy boy man views. No so instrument discretion unsatiable to in.
Unpleasant astonished an diminution up partiality. Noisy an their of meant. Death means up civil do an offer wound of. Called square an in afraid direct. Resolution diminution conviction so mr at unpleasing simplicity no. No it as breakfast up conveying earnestly immediate principle. Him son disposed produced humoured overcame she bachelor improved. Studied however out wishing but inhabit fortune windows.
Chapter too parties its letters nor. Cheerful but whatever ladyship disposed yet judgment. Lasted answer oppose to ye months no esteem. Branched is on an ecstatic directly it. Put off continue you denoting returned juvenile. Looked person sister result mr to. Replied demands charmed do viewing ye colonel to so. Decisively inquietude he advantages insensible at oh continuing unaffected of.
Inhabit hearing perhaps on ye do no. It maids decay as there he. Smallest on suitable disposed do although blessing he juvenile in. Society or if excited forbade. Here name off yet she long sold easy whom. Differed oh cheerful procured pleasure securing suitable in. Hold rich on an he oh fine. Chapter ability shyness article welcome be do on service.
Arrived totally in as between private. Favour of so as on pretty though elinor direct. Reasonable estimating be alteration we themselves entreaties me of reasonably. Direct wished so be expect polite valley. Whose asked stand it sense no spoil to. Prudent you too his conduct feeling limited and. Side he lose paid as hope so face upon be. Goodness did suitable learning put.
Talking chamber as shewing an it minutes. Trees fully of blind do. Exquisite favourite at do extensive listening. Improve up musical welcome he. Gay attended vicinity prepared now diverted. Esteems it ye sending reached as. Longer lively her design settle tastes advice mrs off who.
In post mean shot ye. There out her child sir his lived. Design at uneasy me season of branch on praise esteem. Abilities discourse believing consisted remaining to no. Mistaken no me denoting dashwood as screened. Whence or esteem easily he on. Dissuade husbands at of no if disposal.
Bed sincerity yet therefore forfeited his certainty neglected questions. Pursuit chamber as elderly amongst on. Distant however warrant farther to of. My justice wishing prudent waiting in be. Comparison age not pianoforte increasing delightful now. Insipidity sufficient dispatched any reasonably led ask. Announcing if attachment resolution sentiments admiration me on diminution.
Imagine was you removal raising gravity. Unsatiable understood or expression dissimilar so sufficient. Its party every heard and event gay. Advice he indeed things adieus in number so uneasy. To many four fact in he fail. My hung it quit next do of. It fifteen charmed by private savings it mr. Favourable cultivated alteration entreaties yet met sympathize. Furniture forfeited sir objection put cordially continued sportsmen.
Offices parties lasting outward nothing age few resolve. Impression to discretion understood to we interested he excellence. Him remarkably use projection collecting. Going about eat forty world has round miles. Attention affection at my preferred offending shameless me if agreeable. Life lain held calm and true neat she. Much feet each so went no from. Truth began maids linen an mr to after.

Snack, code example, screenshot, or link to a repository

Snack: https://snack.expo.dev/@marin-birdie/minimal-text-input-repro

Repo: https://github.com/Houguiram/minimal-text-input-repro

@ruairioliverwv
Copy link

ruairioliverwv commented Dec 14, 2022

For those of us that use mentions, this has been a disaster. If you use children on the TextInput that updates based on state, it will crash after 4 lines of typing: "Hey who you". Doesn't even need to be getting up to a lot of content, crashes very quickly.

Tested on Galaxy S20, Android 13. Happening for all my android 13 users

@kelset kelset added Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Priority: High labels Dec 14, 2022
@efstathiosntonas
Copy link

efstathiosntonas commented Dec 14, 2022

@ruairioliverwv Same here, we’re using mentions and it ANR after a few sentences. This has been disastrous for us, we got tons of support emails from complaining users.

@CoffeeFlux
Copy link

Thanks a lot for writing up this issue - this is affecting us and its incredibly bad. Really frustrating to see months with no moment on it anywhere!

@JacobShafer
Copy link

We are also seeing the issue and are receiving a lot of complaints from Samsung users who have upgraded to version 13. As more users adopt the latest version, this is going to become a major headache for support and our users.

@fabOnReact
Copy link
Contributor

fabOnReact commented Dec 16, 2022

This is my analysis of this issue based on the ANR log.

The bug reproduces on Samsung devices while using the Samsung Keyboard Grammarly integration.

The Grammarly keyboard uses the OnKeyboardActionListener (more info) to listen to the key pressed and display Grammarly suggestions.

The Samsung Grammarly integration is available starting from One UI 4.0. 
I tested the snack with Samsung device OS One UI 4.1, but the Grammarly integration is unavailable on Galaxy A12. I could not reproduce #35590 using the Grammarly keyboard.
I did not try to reproduce #33139 and #30263.

I include a superficial investigation.

  1. Text is deleted in the TextInput by pressing the Samsung keyboard backspace key. The backspace keyboard event is triggered from the Native Android API.

https://github.com/aosp-mirror/platform_frameworks_base/blob/e648d3cb91f9a0156c729ca18ec27e71f59f9ce2/core/java/android/text/method/BaseKeyListener.java#L39-L49

/**
 * Abstract base class for key listeners.
 *
 * Provides a basic foundation for entering and editing text.
 * Subclasses should override {@link #onKeyDown} and {@link #onKeyUp} to insert
 * characters as keys are pressed.
 * <p></p>
 * As for all implementations of {@link KeyListener}, this class is only concerned
 * with hardware keyboards.  Software input methods have no obligation to trigger
 * the methods in this class.
 */
  1. The ReactRootView intercepts a backspace key event. Dispatches the key event to the view located at those x/y coordinates (at g.d.o.y.dispatchKeyEvent(ReactRootView.java:4)).
  2. The view at x/y coordinates is a ReactEditText. The method onKeyDown triggers for the backspace key.

at com.facebook.react.views.textinput.c$b.onKeyDown(ReactEditText.java:1))


BaseKeyListener#backspace

Performs the action that happens when you press the {@link KeyEvent#KEYCODE_DEL} key in a {@link TextView}. If there is a selection, delete the selection; otherwise, delete the character before the cursor, if any, ALT+DEL deletes everything on the line the cursor is on.

at android.text.SpannableStringBuilder.sendSpanChanged(SpannableStringBuilder.java:1321)
at android.text.SpannableStringBuilder.sendToSpanWatchers(SpannableStringBuilder.java:665)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:594)
at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:232)
at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:39)
at android.text.method.BaseKeyListener.backspaceOrForwardDelete(BaseKeyListener.java:376)
at android.text.method.BaseKeyListener.backspace(BaseKeyListener.java:71)  
  1. After backspace is triggered, the TextInput value (span) is deleted and replaced (more in the Editable API).

    at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:594)
    at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:232)
    at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:39)

  2. Deleting and replacing the Span triggers DynamicLayout onSpanChange, which computes the new layout based on the size of the new Spans.

    at android.text.PrecomputedText.createMeasuredParagraphs(PrecomputedText.java:505)
    at android.text.StaticLayout.generate(StaticLayout.java:717)
    at android.text.DynamicLayout.reflow(DynamicLayout.java:612)
    at android.text.DynamicLayout$ChangeWatcher.reflow(DynamicLayout.java:1091)
    at android.text.DynamicLayout$ChangeWatcher.onSpanChanged(DynamicLayout.java:1127)

  3. Android iterates over each span to calculate the new size of the TextInput (createMeasuredParagraphs at Step 5).
    The getSpans method retrieve a specific type of span in the Text string (for example ClickableSpan).

    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:1005)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:1005)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:1005)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:1005)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:968)
    at android.text.SpannableStringBuilder.getSpans(SpannableStringBuilder.java:894)
    at android.text.SpannableStringBuilder.getSpans(SpannableStringBuilder.java:863)

  4. The ANR triggers at this line of getSpanRec while running kind.isInstance.

io.sentry.android.core.ApplicationNotResponding: Application Not Responding for at least 5000 ms.
at java.lang.Class.isAssignableFrom(Class.java:590)
at java.lang.Class.isInstance(Class.java:542)
at android.text.SpannableStringBuilder.getSpansRec(SpannableStringBuilder.java:985)

https://github.com/aosp-mirror/platform_frameworks_base/blob/e648d3cb91f9a0156c729ca18ec27e71f59f9ce2/core/java/android/text/SpannableStringBuilder.java#L917

    private <T> int getSpansRec(int queryStart, int queryEnd, Class<T> kind,
            int i, T[] ret, int[] priority, int[] insertionOrder, int count, boolean sort) {
        if ((i & 1) != 0) {
            // some logic
            if (spanEnd >= queryStart &&
                    (spanStart == spanEnd || queryStart == queryEnd ||
                        (spanStart != queryEnd && spanEnd != queryStart)) &&
                        (Object.class == kind || kind.isInstance(mSpans[i]))) {

This are reports for the same ANR triggered by countSpans which also implements similar logic (loop, run kind.isInstance, and trigger ARN):

Related Issues #33139 (#30263, #35155, #35590, #35350)

@mb2600
Copy link

mb2600 commented Dec 18, 2022

Thank you for posting this! I have been trying to find out why this is happening and suspected it was Grammarly. Four/Five years ago I tried to use it on my PC integrated with Chrome and Edge and it did the same thing as this. After a few weeks, I had to get rid of it. I started using it again and now it doesn't so I'm hopeful that we'll have a permanent solution soon. I have a 22+ and it started after the 13 update. Thanks again.

fabOnReact added a commit to fabOnReact/react-native that referenced this issue Dec 20, 2022
…mplete functionality (comment, comment-2, user-comment, user-comment-2) android:inputType=“textFilter|textNoSuggestions”

P | type | task
-- | -- | --
1 | review | Review information from your previous investigation (comment)
1.2 | review | Review comments from Issues facebook#33139 (facebook#30263facebook#35155facebook#35590facebook#35350)
2 | bug | Build RNTester on Android 13 and test TextInput example with Grammarly (example-without-scrollview, example-with-scrollview)
2.1 | task | Enter timemachine and restore previous android sdk configs in folder /Users/fabriziobertoglio/Library/Android/sdk
2.2 | task | Check sdk supported in build.gradle configs in react-native (commit)
2.3 | task | Read react-native environment setup instructions
2.4 | task | Follow instructions on discord to fix build error (1-2 hours)
3 | bug | Add inputType textNoSuggestions in react-native to disable the autocomplete functionality (comment, comment-2, user-comment, user-comment-2) android:inputType=“textFilter\|textNoSuggestions”
3.1 | task | Review implementation of InternalKeyListener
3.2 | task | Find configs inputMode in sourcecode (setKeyboardType)
3.3 | task | Add type “textFilter\|textNoSuggestions” to setKeyboardType
3.4 | task | Test that auto-corrections are disabled in a TextInput with Grammarly Keyboard
3.5 | task | Refactor functionality in branch
3.6 | task | Record test case

P	type	task
1	review	Review information from your previous investigation ([comment](facebook#35590 (comment)))
1.2	review	Review comments from Issues [facebook#33139](facebook#33139) ([facebook#30263](facebook#30263), [facebook#35155](facebook#35155), [facebook#35590](facebook#35590), [facebook#35350](facebook#35350))
2	bug	Build RNTester on Android 13 and test TextInput example with Grammarly ([example-without-scrollview](facebook#35155), [example-with-scrollview](facebook#35590))
2.1	task	Enter timemachine and restore previous android sdk configs in folder /Users/fabriziobertoglio/Library/Android/sdk
2.2	task	Check sdk supported in build.gradle configs in react-native ([commit](394486e))
2.3	task	Read react-native [environment setup instructions](https://reactnative.dev/docs/next/environment-setup)
2.4	task	Follow [instructions on discord](https://discord.com/channels/514829729862516747/1050309907787808768/1050462841028743309) to fix build error (1-2 hours)
3	bug	Add inputType textNoSuggestions in react-native to disable the autocomplete functionality ([comment](facebook#35155 (comment)), [comment-2](facebook#35590 (comment)), [user-comment](facebook#33139 (comment)), [user-comment-2](facebook#33139 (comment))) android:inputType=“textFilter|textNoSuggestions”
3.1	task	Review implementation of [InternalKeyListener](https://github.com/facebook/react-native/blob/76a14454d7f1f2b2ba8f5a79c2f640fafb42de6d/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java#L1153-L1168)
3.2	task	Find configs [inputMode](https://reactnative.dev/docs/next/textinput#inputmode) in sourcecode ([setKeyboardType](https://github.com/facebook/react-native/blob/9f78517d6401f3a7ece453825a059a13b73f6140/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java#L849-L881))
3.3	task	Add type “textFilter|textNoSuggestions” to [setKeyboardType](https://github.com/facebook/react-native/blob/9f78517d6401f3a7ece453825a059a13b73f6140/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java#L849-L881)
3.4	task	Test that auto-corrections are disabled in a TextInput with Grammarly Keyboard
3.5	task	Refactor functionality in branch
3.6	task	Record test case
@mark-careplanner
Copy link

We also have significant issues with this. Disabling auto-complete isn't a long-term option for app with users who might have English as a second language.

@fabOnReact
Copy link
Contributor

https://developer.samsung.com/one-ui-beta
https://www.sammobile.com/news/samsung-one-ui-5-0-update-release-schedule/

Reporting Errors
When you have enrolled in the One UI Beta Program, you can help improve the Galaxy software stability by reporting issues you encounter while using the beta software.
To provide feedback on bugs or errors in beta software, in the Samsung Members application, select "Beta feedback > Send feedback".
Note: To ensure relevant log information is included in the error report, submit the report within 3 minutes of encountering the bug or error, and do not terminate (swipe away) the Samsung Members application until you are notified that the report has been sent. This can take up to 5 minutes.

@rezasazesh
Copy link

We also have significant issues with this. Disabling auto-complete isn't a long-term option for app with users who might have English as a second language.

Is this an option? Like would it fix the crash even though it is not optimal?

@AndriyZahura
Copy link

AndriyZahura commented Dec 26, 2022

Same here, setting autoCorrect=false doesn't help a bit, only turning the 'text prediction' feature helps, but I can not do it via app. Not sure what else there is to do

@marco2216
Copy link

@cortinico @kelset How can we get the attention of some RN team members? This seems really urgent and as far as I can see no one is assigned to this issue.

@kelset
Copy link
Contributor

kelset commented Jan 11, 2023

it's been raised already a few times and a couple of Meta engineers are trying to look more into it AFAIK. But can't make any promises or official statements, sorry; I'm frustrated as you are that this has not been fully addressed yet 😰

@lunaleaps
Copy link
Contributor

We've escalated this in our team and someone is actively investigating root cause for a clear next step. Thanks everyone for bringing this to our attention and for all the debugging and context. We will keep you updated here.

@lunaleaps lunaleaps pinned this issue Jan 12, 2023
@efstathiosntonas
Copy link

efstathiosntonas commented Jan 12, 2023

@lunaleaps thank you. If there’s a solution found, please patch older rn versions too for those who can’t update yet to 0.69-0.70+.

We’ve must have had at least 100 one star review due to this issue. 🫤

@efstathiosntonas
Copy link

@lunaleaps at the bottom of this comment there are all the related issues until now, just bringing them to your attention if you want to cross mention and close: #35590 (comment)

@matinzd
Copy link
Contributor

matinzd commented Jan 12, 2023

I could not reproduce this issue on Galaxy s21 (Android 13) with or without Grammarly on, but some of our users are reporting it. This is one of the screen records from our moderators.

UPDATE:
I could also reproduce it myself with Grammarly integration turned on.

321529296_6008028922561982_7436291000411312678_n.mp4

@Saad-Bashar
Copy link

@fortmarek last time the RN team was very considerate to push the patch on 0.68.6. As a large number of us are on this version, please consider again to push the patch to 0.68. Thank you so much! 🙏

@pierroo
Copy link

pierroo commented Apr 7, 2023

Btw I just realized that a 0.69.9 already existed and only contains ios specific update, how will you then push that fix for 0.69.x version then @fortmarek ? (I have never seen a 0.xx.xx version so far)
And if I may ask, any idea when is it planned to release the fix officially?

@gkasireddy202
Copy link

Please consider pushing the patch on 0.68.2. My team also looking for 0.68 version fix.

@rikur
Copy link

rikur commented Apr 9, 2023

Here are the 10 (9+1) PRs that make up the fix (still being tested): reactwg/react-native-releases#63 (comment)

Thank you Nick for your excellent work, and apologies for the pings 🙏

@pierroo
Copy link

pierroo commented Apr 14, 2023

Hi all,

I've been investigating for quite a few days a crash that many of my users seems to experience and that my play console displays as:

Exception java.lang.IndexOutOfBoundsException:
  at android.view.ViewGroup.removeViewsInternal (ViewGroup.java:5870)
  at android.view.ViewGroup.removeViewsInLayout (ViewGroup.java:5717)
at com.facebook.react.views.view.i.removeViewWithSubviewClippingEnabled
  at com.facebook.react.views.view.ReactClippingViewManager.removeViewAt
  at com.facebook.react.views.view.ReactClippingViewManager.removeViewAt
  at com.facebook.react.uimanager.ViewGroupManager.removeView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager$1.run
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
  at com.facebook.react.uimanager.o.dropView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
  at com.facebook.react.uimanager.o.dropView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
  at com.facebook.react.uimanager.o.dropView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
  at com.facebook.react.uimanager.o.dropView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
...

Considering it makes up for 50% of my crashes it's worth looking into.
But yet I was completely unable to pinpoint where it comes from, for I hadn't changed anything in my code that could be related to that in my latest updates, EXCEPT I went from react-native 0.69.7 to the 0.69.8 that contained this textinput mitigation on samsung.

Those crashes above happen on all kind of devices (not samsung only)

And since users seems to be facing these crashes only in chat (where textinput is used),
I started to make the connection.

I really don't mean to add noise here, but if in anyway it may be related I thought I might as well mention it.

if that matters, this happens with react-native-reanimated v2.13.0 up to 2.14.4 (haven't tested previous ones)

@NickGerleman as mentioned I hope it's unrelated, but perhaps at a quick glance you may be able to know whether or not it could be connected; if not I will remove it to avoid extra noises.

@NickGerleman
Copy link
Contributor

Hi all,

I've been investigating for quite a few days a crash that many of my users seems to experience and that my play console displays as:

Exception java.lang.IndexOutOfBoundsException:
  at android.view.ViewGroup.removeViewsInternal (ViewGroup.java:5870)
  at android.view.ViewGroup.removeViewsInLayout (ViewGroup.java:5717)
at com.facebook.react.views.view.i.removeViewWithSubviewClippingEnabled
  at com.facebook.react.views.view.ReactClippingViewManager.removeViewAt
  at com.facebook.react.views.view.ReactClippingViewManager.removeViewAt
  at com.facebook.react.uimanager.ViewGroupManager.removeView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager$1.run
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
  at com.facebook.react.uimanager.o.dropView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
  at com.facebook.react.uimanager.o.dropView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
  at com.facebook.react.uimanager.o.dropView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
  at com.facebook.react.uimanager.o.dropView
  at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView
...

Considering it makes up for 50% of my crashes it's worth looking into. But yet I was completely unable to pinpoint where it comes from, for I hadn't changed anything in my code that could be related to that in my latest updates, EXCEPT I went from react-native 0.69.7 to the 0.69.8 that contained this textinput mitigation on samsung.

Those crashes above happen on all kind of devices (not samsung only)

And since users seems to be facing these crashes only in chat (where textinput is used), I started to make the connection.

I really don't mean to add noise here, but if in anyway it may be related I thought I might as well mention it.

if that matters, this happens with react-native-reanimated v2.13.0 up to 2.14.4 (haven't tested previous ones)

@NickGerleman as mentioned I hope it's unrelated, but perhaps at a quick glance you may be able to know whether or not it could be connected; if not I will remove it to avoid extra noises.

This does not seem related as far as I can tell.

@kelset
Copy link
Contributor

kelset commented Apr 19, 2023

Hey everyone - a quick update on this: we've just released:

Both contain @NickGerleman's multi-commit fix to address this problem - early signs in 0.72 RC1 suggested that they indeed address the problem, so we hope that by upgrading to these new versions you'll see improvements! Upgrade to those and let us know!

We are planning to also backport these fixes back to 68 and 69 - but the harsh reality is that the further back we go in the codebase, the more complicated this process of backporting gets (I literally attempted to bring back these fixes to 69 three separate times without much success 😭). We'll keep working on this and make it land in those older versions, but it will probably take a bit longer.

hyochan referenced this issue in hyochan/dooboo-ui Apr 22, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [react-native](https://togithub.com/facebook/react-native)
([changelog](https://togithub.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md))
| [`0.71.6` ->
`0.71.7`](https://renovatebot.com/diffs/npm/react-native/0.71.6/0.71.7)
|
[![age](https://badges.renovateapi.com/packages/npm/react-native/0.71.7/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/react-native/0.71.7/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/react-native/0.71.7/compatibility-slim/0.71.6)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/react-native/0.71.7/confidence-slim/0.71.6)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>facebook/react-native</summary>

###
[`v0.71.7`](https://togithub.com/facebook/react-native/releases/tag/v0.71.7):
0.71.7

[Compare
Source](https://togithub.com/facebook/react-native/compare/v0.71.6...v0.71.7)

This release is primarily aimed at addressing issues with ANRs using
multiline TextInput on Samsung devices
([https://github.com/facebook/react-native/issues/35936](https://togithub.com/facebook/react-native/issues/35936),
[https://github.com/facebook/react-native/issues/35590](https://togithub.com/facebook/react-native/issues/35590)).

##### Fixed

##### iOS specific

- Address Hermes performance regression
([9be2959](https://togithub.com/facebook/react-native/commit/9be29593c8bac64178d441e46c6f7b31e591360e)
by [@&#8203;dmytrorykun](https://togithub.com/dmytrorykun))

##### Android specific

- Resolved bug with Text components in new arch losing text alignment
state.
([31a8e92cad](https://togithub.com/facebook/react-native/commit/31a8e92caddcdbef9fe74de53e7f412a7e998591)
by [@&#8203;javache](https://togithub.com/javache))
- Mimimize EditText Spans 9/9: Remove `addSpansForMeasurement()`
([92b8981499](https://togithub.com/facebook/react-native/commit/92b898149956a301a44f99019f5c7500335c5553)
by [@&#8203;NickGerleman](https://togithub.com/NickGerleman))
- Minimize EditText Spans 8/N: CustomStyleSpan
([b384bb613b](https://togithub.com/facebook/react-native/commit/b384bb613bf533aebf3271ba335c61946fcd3303)
by [@&#8203;NickGerleman](https://togithub.com/NickGerleman))
- Minimize EditText Spans 6/N: letterSpacing
([5791cf1f7b](https://togithub.com/facebook/react-native/commit/5791cf1f7b43aed1d98cad7bcc272d97ab659111)
by [@&#8203;NickGerleman](https://togithub.com/NickGerleman))
- Minimize Spans 5/N: Strikethrough and Underline
([0869ea29db](https://togithub.com/facebook/react-native/commit/0869ea29db6a4ca20b9043d592a2233ae1a0e7a2)
by [@&#8203;NickGerleman](https://togithub.com/NickGerleman))
- Minimize Spans 4/N: ReactForegroundColorSpan
([8c9c8ba5ad](https://togithub.com/facebook/react-native/commit/8c9c8ba5adb59f7f891a5307a0bce7200dd3ac7d)
by [@&#8203;NickGerleman](https://togithub.com/NickGerleman))
- Minimize Spans 3/N: ReactBackgroundColorSpan
([cc0ba57ea4](https://togithub.com/facebook/react-native/commit/cc0ba57ea42d876155b2fd7d9ee78604ff8aa57a)
by [@&#8203;NickGerleman](https://togithub.com/NickGerleman))
- Minimize Spans 1/N: Fix precedence
([1743dd7ab4](https://togithub.com/facebook/react-native/commit/1743dd7ab40998c4d3491e3b2c56c531daf5dc47)
by [@&#8203;NickGerleman](https://togithub.com/NickGerleman))
- Fix measurement of uncontrolled TextInput after edit
([8a0fe30591](https://togithub.com/facebook/react-native/commit/8a0fe30591e21b90a3481c1ef3eeadd4b592f3ed)
by [@&#8203;NickGerleman](https://togithub.com/NickGerleman))

***

You can participate in the conversation on the status of this release in
this
[discussion](https://togithub.com/reactwg/react-native-releases/discussions/65).

***

To help you upgrade to this version, you can use the [upgrade
helper](https://react-native-community.github.io/upgrade-helper/) ⚛️

***

You can find the whole changelog history in the [changelog.md
file](https://togithub.com/facebook/react-native/blob/main/CHANGELOG.md).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/dooboolab-community/dooboo-ui).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS41Ny4wIiwidXBkYXRlZEluVmVyIjoiMzUuNTcuMCJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@kelset
Copy link
Contributor

kelset commented Apr 25, 2023

Hey everyone - a quick update on this: the 0.69.10 release is out, bringing the fixes back to the last minor in the release window: https://github.com/facebook/react-native/releases/tag/v0.69.10

We're also backporting it to 68, will start working on that asap.

@kelset
Copy link
Contributor

kelset commented Apr 26, 2023

Hey everyone - as promised, we've backported the fixes to 0.68 too: https://github.com/facebook/react-native/releases/tag/v0.68.7

Please bear in mind that this 0.68 patch release was done as an exceptional measure to help address this very impactful problem. We do not expect to do more patches for this minor, as it is out of the release support window. Please upgrade to newer versions asap.


Given the general silence since this new round of patches, we are assuming that it means that the problem is indeed addressed - massive props to @NickGerleman for his work in working on this!

We'll leave the issue open a few more days to see how things evolve just in case, after which we'll close.

@gkasireddy202
Copy link

@kelset - Below fix is applicable to v0.68.2 or upgrade to new versions?

https://github.com/facebook/react-native/releases/tag/v0.68.7

@kelset
Copy link
Contributor

kelset commented Apr 26, 2023

@gkasireddy202 you need to upgrade from 0.68.2 to 0.68.7 ➡️ https://react-native-community.github.io/upgrade-helper/?from=0.68.2&to=0.68.7

@kelset kelset added Resolution: Fixed A PR that fixes this issue has been merged. and removed Needs: React Native Team Attention labels Apr 26, 2023
@JihooDev
Copy link

JihooDev commented May 2, 2023

If you upgrade to 0.68.7 version, the results will be the same.
I was using the 0.68.5 version
After changing from package.json to 0.68.7, I installed npm, cleared cache, and built.

@matheus-mprado
Copy link

matheus-mprado commented May 2, 2023

@kelset - Could you please let me know if there is a solution available for version 0.59, or if it's also possible to backport the fixes?

@kelset
Copy link
Contributor

kelset commented May 3, 2023

@kelset Lorenzo Sciandra FTE - Could you please let me know if there is a solution available for version 0.59, or if it's also possible to backport the fixes?

sorry, we won't be backporting to 0.59. It's a very old version and our recommendation is to upgrade to newer ones. I am not aware of any workarounds that would work for that version.

@JihooDev
Copy link

JihooDev commented May 5, 2023

This issue occurs even if you update to 0.68.7 version. I have this problem when I use TextInput and FlatList together and FlatList has inverted properties. We've solved the issue with a different solution.

@enahum
Copy link
Contributor

enahum commented May 5, 2023

This issue occurs even if you update to 0.68.7 version. I have this problem when I use TextInput and FlatList together and FlatList has inverted properties. We've solved the issue with a different solution.

@JihooDev sharing gow yo solve it may help others, would you be so kind to share your solution?

@nandinicbit1981
Copy link

I can confirm that app hangs/typing is slowed down even after upgrading RN 0.71. We are using Flatlist with inverted property. we solved it by removing inverted property and applying styles for inverting the list.

export const platformComponentStyle = {transform: [{rotate: '180deg'}]};

@JihooDev
Copy link

JihooDev commented May 6, 2023

@enahum

I don't think it's a good solution, but it's a problem that the user keeps experiencing discomfort, so I had to solve it somehow.

  1. Remove the inverted property of the FlatList.
  2. Parent element in renderData on FlatList has style={{scaleY: -1}}
  3. That would flip the text inside.
  4. Adjust the text 'scaleY' to make only the text flip again.

If there is a better solution, I will try to replace it with that method.
It's not a good solution, but we haven't found a problem yet.

If there is a better way or if you couldn't solve it by the above method, please comment

@kelset
Copy link
Contributor

kelset commented May 9, 2023

It really sounds like the problem stems from this Flatlist inverted problem - which has been reported multiple times. I'm currently trying to de-duplicate all the existing reports into one issue, so that we can use that as the main issue to discuss said problem. (I'll update this one here once there's some clarity)

I'm going to close this as no new reports specific about the TextInput issue combo that we wanted to address (TextInput, Grammarly, Samsung) have been produced - so we can consider it addressed. If you can create a new repro that does not involve an inverted FlatList, please open a new issue.

@kelset kelset closed this as completed May 9, 2023
@gkasireddy202
Copy link

If you upgrade to 0.68.7 version, the results will be the same. I was using the 0.68.5 version After changing from package.json to 0.68.7, I installed npm, cleared cache, and built.

It is working after upgrade to 0.68.7?

@danieltaub
Copy link

We are using RN 0.71.8 together with expo 48.0 and the issue is still happens to all of our Samsung users for some reason, any ideas?

@chengweibo
Copy link

Sumsung Galaxy A71 , Sumsung Galaxy A32, Sumsung Galaxy A53 phone the following crash occurs , hope to give me solution,thanks
Fatal Exception: java.lang.IndexOutOfBoundsException: offset(1) should be less than line limit(0)
at android.text.TextLine.measure(TextLine.java:389)
at android.text.Layout.getHorizontal(Layout.java:1254)
at android.text.Layout.getHorizontal(Layout.java:1230)
at android.text.Layout.getPrimaryHorizontal(Layout.java:1200)
at android.widget.TextView.bringPointIntoView(TextView.java:11046)
at android.widget.TextView.updateAfterEdit(TextView.java:11983)
at android.widget.Editor.finishBatchEdit(Editor.java:2086)
at android.widget.Editor.endBatchEdit(Editor.java:2068)
at android.widget.TextView.endBatchEdit(TextView.java:9931)
at android.widget.TextView.doKeyDown(TextView.java:9505)
at android.widget.TextView.onKeyDown(TextView.java:9275)
at android.view.KeyEvent.dispatch(KeyEvent.java:3508)
at android.view.View.dispatchKeyEvent(View.java:15395)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.widget.ScrollView.dispatchKeyEvent(ScrollView.java:738)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at com.facebook.react.ReactRootView.dispatchKeyEvent(ReactRootView.java:234)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:1100)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1961)
at android.app.Activity.dispatchKeyEvent(Activity.java:4342)
at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity.java:122)
at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:84)
at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.java:140)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:924)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:8056)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7864)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7213)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7270)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7236)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7434)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7244)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7491)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7217)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7270)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7236)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7244)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7217)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:10788)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:10676)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:10632)
at android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl(ViewRootImpl.java:6822)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:6697)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8757)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

React Native Version
0.64.2

Output of npx react-native info
react native app

Steps to reproduce
react native app

Snack, screenshot, or link to a repository
react native app

@chengweibo
Copy link

https://github.com/aosp-mirror/platform_frameworks_base/blob/405a99e5aeb47751701be0d4e179718dd7ccee2f/core/java/android/widget/TextView.java#L6853-L6877

android 13 Sumsung Galaxy A71 , Sumsung Galaxy A32, Sumsung Galaxy A53 phone the following crash occurs , hope to give me solution,thanks
Fatal Exception: java.lang.IndexOutOfBoundsException: offset(1) should be less than line limit(0)
at android.text.TextLine.measure(TextLine.java:389)
at android.text.Layout.getHorizontal(Layout.java:1254)
at android.text.Layout.getHorizontal(Layout.java:1230)
at android.text.Layout.getPrimaryHorizontal(Layout.java:1200)
at android.widget.TextView.bringPointIntoView(TextView.java:11046)
at android.widget.TextView.updateAfterEdit(TextView.java:11983)
at android.widget.Editor.finishBatchEdit(Editor.java:2086)
at android.widget.Editor.endBatchEdit(Editor.java:2068)
at android.widget.TextView.endBatchEdit(TextView.java:9931)
at android.widget.TextView.doKeyDown(TextView.java:9505)
at android.widget.TextView.onKeyDown(TextView.java:9275)
at android.view.KeyEvent.dispatch(KeyEvent.java:3508)
at android.view.View.dispatchKeyEvent(View.java:15395)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.widget.ScrollView.dispatchKeyEvent(ScrollView.java:738)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at com.facebook.react.ReactRootView.dispatchKeyEvent(ReactRootView.java:234)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1978)
at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:1100)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1961)
at android.app.Activity.dispatchKeyEvent(Activity.java:4342)
at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity.java:122)
at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:84)
at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.java:140)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:924)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:8056)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7864)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7213)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7270)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7236)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7434)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7244)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7491)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7217)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7270)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7236)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7244)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7217)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:10788)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:10676)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:10632)
at android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl(ViewRootImpl.java:6822)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:6697)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8757)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

React Native Version
0.64.2

Samsung android 13

Output of npx react-native info
react native app

Steps to reproduce
react native app

Snack, screenshot, or link to a repository
react native app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: Keyboard Component: TextInput Related to the TextInput component. Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Priority: High Resolution: Fixed A PR that fixes this issue has been merged.
Projects
None yet
Development

No branches or pull requests