question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ApplicationNotResponding android.text.SpannableStringBuilder in getSpanStart

See original GitHub issue

Description

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)

Screen Shot 2022-02-10 at 12 32 15

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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kj800xcommented, Mar 4, 2022

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 disables autoCorrect (and so also the buggy samsung feature) for Samsung users on Android 12.

import { getBrand, getSystemVersion } from 'react-native-device-info';

function MyComponent() {
  return <TextInput autoCorrect={getBrand() !== 'samsung' || getSystemVersion() !== '12'} />
}

image image image

0reactions
github-actions[bot]commented, Oct 25, 2022

This issue was closed because it has been stalled for 7 days with no activity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android.text.SpannableStringBuilder.getSpanStart java code ...
public static void replaceUnderlineSpans(SpannableStringBuilder builder, Resources resources) { UnderlineSpan[] underlineSpans = builder.
Read more >
SpannableStringBuilder | Android Developers
Create a new SpannableStringBuilder with empty contents. SpannableStringBuilder(CharSequence text) ... public int getSpanStart (Object what).
Read more >
Android SpannableStringBuilder IndexOutOfBoundsException
So the solution was to remove the interface and always set the text of given TextView to null in onDestroyView method of given...
Read more >
tests/tests/text/src/android/text/cts/SpannableStringTest.java
SpannableStringBuilder ;. import android.text. ... SpannableString spannable = new SpannableString(text);. spannable. ... getSpanStart(underlineSpan));.
Read more >
android.text.spannablestringbuilder#getSpanStart
This page shows Java code examples of android.text.spannablestringbuilder#getSpanStart.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found