ApplicationNotResponding android.text.SpannableStringBuilder in getSpanStart
See original GitHub issueDescription
Certain users are getting their app crashed while typing in a text input. From Sentry we where able to get this log:
io.sentry.android.core.ApplicationNotResponding: Application Not Responding for at least 5000 ms.
at android.text.SpannableStringBuilder.getSpanStart(SpannableStringBuilder.java:828)
at android.text.TextUtils.removeEmptySpans(TextUtils.java:2004)
at android.text.MeasuredParagraph.buildForStaticLayout(MeasuredParagraph.java:431)
at android.text.PrecomputedText.createMeasuredParagraphs(PrecomputedText.java:436)
at android.text.StaticLayout.generate(StaticLayout.java:706)
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:1126)
at android.text.SpannableStringBuilder.sendSpanChanged(SpannableStringBuilder.java:1318)
at android.text.SpannableStringBuilder.sendToSpanWatchers(SpannableStringBuilder.java:662)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:591)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:518)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:39)
at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:945)
at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:219)
at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:204)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:561)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:118)
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:8641)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
Device details from this example:
SM-G988U Model:SP1A.210812.016 android 12
You can see in this screenshot - Sentry catches a lot of different ANRs, but it looks like most of them is related to the input component (maybe even all of them… I don’t have enough insights on the code to know)
Version
0.66.0
Output of npx react-native info
System: OS: macOS 12.1 CPU: (8) x64 Intel® Core™ i7-1068NG7 CPU @ 2.30GHz Memory: 44.38 MB / 32.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 16.13.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 8.1.0 - /usr/local/bin/npm Watchman: Not Found Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: API Levels: 28, 29, 30, 31 Build Tools: 30.0.2, 31.0.0 System Images: android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Google APIs ARM 64 v8a, android-31 | Google Play Intel x86 Atom_64, android-32 | Google Play Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8139111 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.0 => 0.66.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
We were not able to reproduce, but the users it happen to - report that this is happening very often. And Sentry logs & Google play logs - show those ANRs that happen again and again.
Snack, code example, screenshot, or link to a repository
This is just a simple text input component… not much to share… 🤔
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9 (2 by maintainers)
My team has been receiving support requests and the same sentry report. All the reports seem to be for Samsung users on Android 12 with the suggest text corrections feature enabled.
We were able to reproduce it on a test device. It seemed like the larger the value was and the more suggestions that the feature suggested, the worse the slowdowns became. After about two paragraphs of text the app started becoming noticably unresponsive.
It seems that setting the
autoCorrect={false}
prop on the text field prevents the suggest text corrections feature from running and after setting it we weren’t seeing any slowdowns. Right now we’re putting out a bug fix which disablesautoCorrect
(and so also the buggy samsung feature) for Samsung users on Android 12.This issue was closed because it has been stalled for 7 days with no activity.