App icon indicating copy to clipboard operation
App copied to clipboard

[Crashlytics] ReactTextInputManager$ReactTextInputTextWatcher.onTextChanged

Open muttmuure opened this issue 1 year ago • 5 comments

Device Brand:Samsung Model:Galaxy A03s Orientation:Portrait RAM free: 935.64 MB Disk free: 1.52 GB Operating System Version:Android 13 Orientation:Portrait Rooted:No Crash Date:Jul 8, 2024, 2:49:52 PM App version:9.0.5-3 (1009000503)

com.facebook.react.views.textinput ReactTextInputManager.java:1048

java.lang.StringIndexOutOfBoundsException - length=4; index=5
          Fatal Exception: java.lang.StringIndexOutOfBoundsException: begin 0, end 31, length 30
       at java.lang.String.checkBoundsBeginEnd(String.java:4466)
       at java.lang.String.substring(String.java:2517)
       at com.facebook.react.views.textinput.ReactTextInputManager$ReactTextInputTextWatcher.onTextChanged(ReactTextInputManager.java:1049)
       at com.facebook.react.views.textinput.ReactEditText$TextWatcherDelegator.onTextChanged(ReactEditText.java:1271)
       at android.widget.TextView.sendOnTextChanged(TextView.java:11881)
       at android.widget.TextView.handleTextChanged(TextView.java:12010)
       at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:15271)
       at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1281)
       at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:590)
       at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:315)
       at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:521)
       at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:305)
       at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:49)
       at com.facebook.react.views.textinput.ReactEditText.maybeSetText(ReactEditText.java:701)
       at com.facebook.react.views.textinput.ReactEditText.maybeSetTextFromState(ReactEditText.java:646)
       at com.facebook.react.views.textinput.ReactTextInputManager.updateExtraData(ReactTextInputManager.java:384)
       at com.facebook.react.views.textinput.ReactTextInputManager.updateExtraData(ReactTextInputManager.java:85)
       at com.facebook.react.views.view.ReactViewManagerWrapper$DefaultViewManager.updateExtraData(ReactViewManagerWrapper.kt:89)
       at com.facebook.react.fabric.mounting.SurfaceMountingManager.updateState(SurfaceMountingManager.java:1088)
       at com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem.execute(IntBufferBatchMountItem.java:149)
       at com.facebook.react.fabric.mounting.MountItemDispatcher.executeOrEnqueue(MountItemDispatcher.java:359)
       at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems(MountItemDispatcher.java:275)
       at com.facebook.react.fabric.mounting.MountItemDispatcher.tryDispatchMountItems(MountItemDispatcher.java:119)
       at com.facebook.react.fabric.FabricUIManager$3.runGuarded(FabricUIManager.java:802)
       at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:29)
       at com.facebook.react.fabric.FabricUIManager.scheduleMountItem(FabricUIManager.java:806)
       at com.swmansion.reanimated.NativeProxy.performOperations(NativeProxy.java)
       at com.swmansion.reanimated.NodesManager.performOperations(NodesManager.java:208)
       at com.swmansion.reanimated.NodesManager.onEventDispatch(NodesManager.java:315)
       at com.facebook.react.uimanager.events.FabricEventDispatcher.dispatchEvent(FabricEventDispatcher.java:42)
       at com.reactnativekeyboardcontroller.extensions.ThemedReactContextKt.dispatchEvent(ThemedReactContext.kt:17)
       at com.reactnativekeyboardcontroller.listeners.FocusedInputObserver$textListener$1.invoke(FocusedInputObserver.java:55)
       at com.reactnativekeyboardcontroller.listeners.FocusedInputObserver$textListener$1.invoke(FocusedInputObserver.java:53)
       at com.reactnativekeyboardcontroller.extensions.EditTextKt$addOnTextChangedListener$listener$1.onTextChanged(EditText.kt:37)
       at com.facebook.react.views.textinput.ReactEditText$TextWatcherDelegator.onTextChanged(ReactEditText.java:1271)
       at android.widget.TextView.sendOnTextChanged(TextView.java:11881)
       at android.widget.TextView.handleTextChanged(TextView.java:12010)
       at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:15271)
       at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1281)
       at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:590)
       at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:315)
       at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:521)
       at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:305)
       at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:49)
       at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:945)
       at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:712)
       at android.view.inputmethod.InputConnectionWrapper.setComposingText(InputConnectionWrapper.java:154)
       at android.view.inputmethod.InputConnectionWrapper.setComposingText(InputConnectionWrapper.java:154)
       at com.facebook.react.views.textinput.ReactEditTextInputConnectionWrapper.setComposingText(ReactEditTextInputConnectionWrapper.java:92)
       at com.android.internal.inputmethod.RemoteInputConnectionImpl.lambda$setComposingText$25$com-android-internal-inputmethod-RemoteInputConnectionImpl(RemoteInputConnectionImpl.java:724)
       at com.android.internal.inputmethod.RemoteInputConnectionImpl$$ExternalSyntheticLambda19.run(:8)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8779)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

muttmuure avatar Jul 09 '24 10:07 muttmuure

Triggered auto assignment to @Christinadobrzyn (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

melvin-bot[bot] avatar Jul 09 '24 10:07 melvin-bot[bot]

Hi! I'm Olimpia from Callstack and I'd like to work on this issue.

OlimpiaZurek avatar Jul 09 '24 10:07 OlimpiaZurek

Awesome! Thank you @OlimpiaZurek!

Christinadobrzyn avatar Jul 09 '24 15:07 Christinadobrzyn

This error indicates that there is an attempt to access a character in a string at an index that exceeds the string's length( eg. trying to perform operations like substring extraction (substring) or text replacement (replace) on strings, with indices that are out of bounds). This occurs within the ReactTextInputManager class, which handles text change events for TextInput components. We could fix it by adding a check to ensure the string's length is within acceptable limit.

However, I have not been able to reproduce this error, which makes it challenging to identify the exact location where the fix should be applied.

I also couldn't find it in the issue list in the Firebase console.

@muttmuure Can you send me a link to this specific issue in Firebase Crashlytics?

OlimpiaZurek avatar Jul 10 '24 13:07 OlimpiaZurek

Asking in the slack channel for that link - https://expensify.slack.com/archives/C05LX9D6E07/p1720725024310959

Christinadobrzyn avatar Jul 11 '24 19:07 Christinadobrzyn

Here you go: https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues/389a4a865e5148d93b1ea7ef2043b872?time=last-seven-days&types=crash&sessionEventKey=668D25D600E2000112E62C75AF7013A3_1968058714053198528

muttmuure avatar Jul 12 '24 12:07 muttmuure

I'm still investigating this issue.

OlimpiaZurek avatar Jul 15 '24 09:07 OlimpiaZurek

I still haven’t been able to reproduce this crash, likely because it happens infrequently. It was first observed on June 19 and has affected 14 users in 24 events.

As previously mentioned, this issue occurs when we try to use a part of text that does not exist. To resolve it, we'll need to add an additional check to ensure that the string indexes fall within acceptable bounds.

But, without being able to reproduce the crash, pinpointing where exactly to implement this fix is challenging.

Given the crash's limited impact and the difficulty in reproducing it, it does not currently appear to be critical. I will continue monitoring the situation to prevent any potential escalation and ensure it does not disrupt user experience.

OlimpiaZurek avatar Jul 18 '24 07:07 OlimpiaZurek

Sounds good @OlimpiaZurek - TY!

Is there a preferred way for you to monitor this? For example, should I move this GH to a weekly or monthly GH so it can be updated if the crash happens again? Or should I discuss just closing this without action?

Christinadobrzyn avatar Jul 18 '24 17:07 Christinadobrzyn

I think we can move this to monthly GH.

OlimpiaZurek avatar Jul 19 '24 09:07 OlimpiaZurek

This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

MelvinBot avatar Jul 19 '24 15:07 MelvinBot

Awesome! thank you @OlimpiaZurek! I moved it to monthly and added a needs reproduction label. Let me know if there's anything I can do to help!

Christinadobrzyn avatar Jul 19 '24 15:07 Christinadobrzyn

@OlimpiaZurek @Christinadobrzyn this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

melvin-bot[bot] avatar Jul 23 '24 18:07 melvin-bot[bot]

Hi @OlimpiaZurek just checking in on this - do you have any update or have you been able to reproduce this?

Christinadobrzyn avatar Sep 11 '24 16:09 Christinadobrzyn

Hey @Christinadobrzyn. I reviewed the latest Crashlytics report, and it looks like the issue is resolved. The last occurrence of this crash was on August 8th, and there have been no crashes related to this error since app version 9.0.16.8.

OlimpiaZurek avatar Sep 13 '24 11:09 OlimpiaZurek

hi @OlimpiaZurek oh perfect! Thank you for looking into that. Let's close this since the issue is resolved. Thank you!

Christinadobrzyn avatar Sep 13 '24 14:09 Christinadobrzyn