react-native icon indicating copy to clipboard operation
react-native copied to clipboard

TextInput hangs with Samsung keyboard's Grammarly integration

Open Houguiram opened this issue 2 years ago • 69 comments

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

Houguiram avatar Dec 07 '22 12:12 Houguiram

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

ruairioliverwv avatar Dec 14 '22 11:12 ruairioliverwv

@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.

efstathiosntonas avatar Dec 14 '22 17:12 efstathiosntonas

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!

CoffeeFlux avatar Dec 15 '22 01:12 CoffeeFlux

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.

JacobShafer avatar Dec 15 '22 19:12 JacobShafer

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):

  • https://issuetracker.google.com/issues/240455025
  • https://stackoverflow.com/questions/37066986/java-lang-stackoverflowerror-stack-size-8mb-while-enabling-disabling-textviews
  • https://stackoverflow.com/questions/15929894/edittext-causes-stackoverflow
  • https://support.google.com/pixelphone/thread/181332682/keyboard-freezing-after-android-13-update?hl=en

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

fabOnReact avatar Dec 16 '22 17:12 fabOnReact

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.

mb2600 avatar Dec 18 '22 11:12 mb2600

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.

mark-careplanner avatar Dec 21 '22 09:12 mark-careplanner

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

fabOnReact avatar Dec 21 '22 09:12 fabOnReact

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.

fabOnReact avatar Dec 22 '22 09:12 fabOnReact

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?

rezasazesh avatar Dec 22 '22 23:12 rezasazesh

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

AndriyZahura avatar Dec 26 '22 19:12 AndriyZahura

@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.

marco2216 avatar Jan 11 '23 13:01 marco2216

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 😰

kelset avatar Jan 11 '23 13:01 kelset

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 avatar Jan 12 '23 18:01 lunaleaps

@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 avatar Jan 12 '23 19:01 efstathiosntonas

@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: https://github.com/facebook/react-native/issues/35590#issuecomment-1355221060

efstathiosntonas avatar Jan 12 '23 19:01 efstathiosntonas

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.

https://user-images.githubusercontent.com/24797481/212201263-7eeff600-83fd-48f1-af88-0552ff993bc3.mp4

matinzd avatar Jan 12 '23 23:01 matinzd

@matinzd Reproducing it for me sometimes takes a few paragraphs of text, and other times it takes a few sentences.

welch174 avatar Jan 12 '23 23:01 welch174

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.

321529296_6008028922561982_7436291000411312678_n.mp4

It's quite easy to reproduce, just need to do a few text mistakes to make the Grammarly underline errors and suggest corrections, after that in a few next sentences the app will hang on. I have reproduced it on all our React Native apps with the Galaxy Z Fold 3 (android 13)

YuriiLunovSendient avatar Jan 13 '23 07:01 YuriiLunovSendient

Yep, easy to recreate, I just need to write "Hey how you" 5 or 6 times and it crashes. Just wait for grammarly to underline each sentence before going to a new line and typing the same thing again

ruairioliverwv avatar Jan 13 '23 10:01 ruairioliverwv

@lunaleaps not trying to be an ass, are there any updates? Our play store reviews are plummeting 🥺

efstathiosntonas avatar Jan 16 '23 19:01 efstathiosntonas

We pushed a fix to our users that dropped our ARN from 0,81% to 0,02% and stopped complaints for now. We changed out TextInput to email-address but that broke multiline support. IMO is better than having it breaking

<TextInput
  keyboardType={isSamsungWithAndroid13 ? 'email-address' : 'default'}
/>

another possible solution we're aiming to release this week is changing the type to visible-password, which enables "some" multiline support. I'll post once we get it out there.

<TextInput
   keyboardType={isSamsungWithAndroid13 ? 'visible-password' : 'default'}
   {...(isSamsungWithAndroid13 && { returnKeyType: 'none' })}
 />

drdpedroso avatar Jan 17 '23 13:01 drdpedroso

@lunaleaps not trying to be an ass, are there any updates? Our play store reviews are plummeting 🥺

No actionable updates for folks yet. We are still trying to figure out what part of this issue uniquely affects React Native and where exactly we should seek support from as it intersects Samsung's proprietary Android, Android, Grammarly, etc.

If there are actionable items for you guys and/or clear progress, we will update you.

lunaleaps avatar Jan 19 '23 01:01 lunaleaps

@lunaleaps not only with TextInput, but Grammarly also causes many problems with all rich editor component base on html run on WebView. Because of that, we have to use uncontrolled inputs to reduce the impacts on our user devices and switch the rich editor's input mode to url type. Exclude our application from Grammarly can resolve it temporarily, but the Samsung predictive still causes the ANR in a small percentage.

Phong-TH avatar Jan 19 '23 08:01 Phong-TH

Hey all -

We suspected this was a culprit for us, but when we delved in to it a bit more, we discovered this was actually a bug with inverted FlatLists that got a lot worse on Android 13.

Here's the relevant issue: https://github.com/facebook/react-native/issues/30034

I'm posting in case others have the same underlying problem. A text input is often in the same view as an inverted FlatList, for say, instant messaging.

ChrisEdson avatar Jan 19 '23 14:01 ChrisEdson

I can easily reproduce the issue as in below video. The app is unresponsive and eventually crashed.

https://user-images.githubusercontent.com/1075925/213633057-971574b6-aff8-44b7-bd05-ea8aef51ca0a.mp4

And here is the fixed version. The app is responsive now with some fixes and optimisations.

https://user-images.githubusercontent.com/1075925/213634329-788979a7-6d33-48ee-a3e1-510a3acdf83f.mp4

minhnc avatar Jan 20 '23 06:01 minhnc

@ChrisEdson Yes, we have the same use case (TextInput and FlatList components) and lately we patched react-native with this patch. ANRs dropped after this but they are still present.

@minhnc How did you fix this? Is it just the fix for FlatList (mentioned in #30034) or something else?

michalv8 avatar Jan 20 '23 07:01 michalv8

In our cases, it hangs up event if there is no flatlist on the screen at all. So this is not flatlist issue

YuriiLunovSendient avatar Jan 20 '23 07:01 YuriiLunovSendient

@ChrisEdson Yes, we have the same use case (TextInput and FlatList components) and lately we patched react-native with this patch. ANRs dropped after this but they are still present.

@minhnc How did you fix this? Is it just the fix for FlatList (mentioned in #30034) or something else?

I've migrated from controlled to uncontrolled inputs. There're also suggestions to turn off suggestion/auto-correction as mentioned above. But in my case, the app works smoothly with uncontrolled components.

minhnc avatar Jan 20 '23 07:01 minhnc

In our cases, it hangs up event if there is no flatlist on the screen at all. So this is not flatlist issue

Yes please, let's not assume this is only FlatList related; the whole "inverted" flatlist issue was mentioned many times in other threads all with fixes and solution as mentioned above.

The issue here is MUCH bigger and related to ANY input with Samsung default keyboard.

Yes maybe uncontrolled inputs could "improve", but it is not always possible to use uncontrolled inputs and we cannot ask our users to "turn off autocorrect", even more so since most won't care emailing us or asking questions, they will simply uninstall, rate poorly, and leave a ton of ANRs behind.

We are now all cheering and rooting for @lunaleaps , hoping Meta itself finds a solution to this :')

pierroo avatar Jan 20 '23 10:01 pierroo