Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.45k stars 2.81k forks source link

[Crashlytics] ReactTextInputManager$ReactTextInputTextWatcher.onTextChanged #45058

Closed muttmuure closed 3 weeks ago

muttmuure commented 3 months ago

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)
Issue OwnerCurrent Issue Owner: @OlimpiaZurek
melvin-bot[bot] commented 3 months ago

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.

OlimpiaZurek commented 3 months ago

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

Christinadobrzyn commented 3 months ago

Awesome! Thank you @OlimpiaZurek!

OlimpiaZurek commented 2 months ago

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?

Christinadobrzyn commented 2 months ago

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

muttmuure commented 2 months ago

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

OlimpiaZurek commented 2 months ago

I'm still investigating this issue.

OlimpiaZurek commented 2 months ago

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.

Christinadobrzyn commented 2 months ago

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?

OlimpiaZurek commented 2 months ago

I think we can move this to monthly GH.

MelvinBot commented 2 months ago

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

Christinadobrzyn commented 2 months ago

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!

melvin-bot[bot] commented 2 months ago

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

Christinadobrzyn commented 3 weeks ago

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

OlimpiaZurek commented 3 weeks ago

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.

Christinadobrzyn commented 3 weeks ago

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