Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API 31/32 Crashes on comma completion after shouldIgnoreToken triggers #444

Open
phazei opened this issue May 4, 2023 · 1 comment
Open

Comments

@phazei
Copy link

phazei commented May 4, 2023

This hasn't crashed on the emulator for API 28 and 31. This crashes on my Samsung Galaxy S10e running Android 12 One UI 4.1. Very simple tag input, strings only.

    override fun shouldIgnoreToken(token: String): Boolean {
        return objects.contains(token)
    }
Process: com.phazei.dynamicgptchat, PID: 16443
        java.lang.ArrayIndexOutOfBoundsException: src.length=10 srcPos=10 dst.length=10 dstPos=2 length=3
        at java.lang.System.arraycopy(Native Method)
        at android.text.SpannableStringBuilder.moveGapTo(SpannableStringBuilder.java:180)
        at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:387)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:560)
        at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:315)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:518)
        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.commitText(BaseInputConnection.java:219)
        at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:204)
        at android.view.inputmethod.InputConnectionWrapper.commitText(InputConnectionWrapper.java:192)
        at android.view.inputmethod.InputConnectionWrapper.commitText(InputConnectionWrapper.java:192)
        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:8751)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Edit: After more testing, I found that it does happen in the emulator too, on 31 and 32 (28 works). It specifically only crashes when I use the soft keyboard, on either real phone or emulator, to submit the ",". So it's a directly related issue to the other ticket I closed. Here in v4 the issue was fixed for regular input, but whatever it's doing related to shouldIgnoreToken, it's still having a related issue. It does call that method just fine, it's sometime after it's called that it crashes. Works fine with keyboard ",", fails with softkeyboard "," 😔

@phazei phazei changed the title Crashes when shouldIgnoreToken triggers API 31/32 Crashes on comma completion after shouldIgnoreToken triggers May 4, 2023
@phazei
Copy link
Author

phazei commented May 4, 2023

Entered "aaa," then entered "aaa," a second time
TokenCompleteTextView.kt line 839

            } else if (shouldIgnoreToken(tokenSpan.token)) {
                editable.replace(candidateRange.start, candidateRange.end, "")

Edit, never mind, thought this was something. Gets passed here then ends up in a spannable class and crashes. I'm trying to debug but I can't figure it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@phazei and others