JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.24k stars 1.18k forks source link

IllegalArgumentException: end cannot negative. [end: -1] #2023

Closed WolandPL closed 1 month ago

WolandPL commented 2 years ago

I have the following crash in production. The stacktrace doesn't refer to my code in any place and unfortunatelly I'm not able to reproduce it.

Besides everything else - there's missing "be" in the exception message.

Fatal Exception: java.lang.IllegalArgumentException: end cannot negative. [end: -1]
       at androidx.compose.ui.text.TextRangeKt.packWithCheck(TextRangeKt.java:124)
       at androidx.compose.ui.text.TextRangeKt.TextRange(TextRangeKt.java:37)
       at androidx.compose.ui.text.input.EditingBuffer.delete$ui_text_release(EditingBuffer.kt:205)
       at androidx.compose.ui.text.input.DeleteSurroundingTextCommand.applyTo(EditCommand.kt:271)
       at androidx.compose.ui.text.input.EditProcessor.apply(EditProcessor.java:110)
       at androidx.compose.foundation.text.TextFieldKeyInput.apply(TextFieldKeyInput.kt:62)
       at androidx.compose.foundation.text.TextFieldKeyInput.access$apply(TextFieldKeyInput.java:49)
       at androidx.compose.foundation.text.TextFieldKeyInput$process$2.invoke(TextFieldKeyInput.kt:134)
       at androidx.compose.foundation.text.TextFieldKeyInput$process$2.invoke(TextFieldKeyInput.kt:102)
       at androidx.compose.foundation.text.TextFieldKeyInput.commandExecutionContext(TextFieldKeyInput.java:211)
       at androidx.compose.foundation.text.TextFieldKeyInput.process-ZmokQxo(TextFieldKeyInput.java:102)
       at androidx.compose.foundation.text.TextFieldKeyInputKt$textFieldKeyInput$2$1.invoke-ZmokQxo(TextFieldKeyInput.kt:243)
       at androidx.compose.foundation.text.TextFieldKeyInputKt$textFieldKeyInput$2$1.invoke(TextFieldKeyInput.kt:243)
       at androidx.compose.ui.node.ModifiedKeyInputNode.propagateKeyEvent-ZmokQxo(ModifiedKeyInputNode.kt:47)
       at androidx.compose.ui.input.key.KeyInputModifier.processKeyInput-ZmokQxo(KeyInputModifier.java:78)
       at androidx.compose.ui.platform.AndroidComposeView.sendKeyEvent-ZmokQxo(AndroidComposeView.android.kt:562)
       at androidx.compose.ui.platform.AndroidComposeView.dispatchKeyEvent(AndroidComposeView.android.kt:569)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1986)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1986)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1986)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1986)
       at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:946)
       at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1947)
       at android.app.Activity.dispatchKeyEvent(Activity.java:4147)
       at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity.java:122)
       at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:84)
       at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.java:140)
       at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:800)
       at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:7490)
       at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7316)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6709)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6766)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6732)
       at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6911)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6740)
       at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6968)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6713)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6766)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6732)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6740)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6713)
       at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:10001)
       at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:9839)
       at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:9792)
       at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:6313)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:247)
       at android.app.ActivityThread.main(ActivityThread.java:8656)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
leetaehoon-android commented 2 years ago

I faced this issue, too.

https://issuetracker.google.com/issues/199919707

a-poteralowicz commented 2 years ago

I have the same issue, but am only able to reproduce on SM-T500 / Android 11. If you have any workarounds, I would be grateful if you shared 🙏

anil-basantani commented 2 years ago

This issue is reproducible on Samsung devices while pressing "DEL" key from keyboard, It will crash along with above crash logs. I'm also facing same issue.

felixdivo commented 2 years ago

I had this problem too on Desktop (Windows), but it seems to be resolved in v1.2.0-alpha01-dev741.

ahmed-shehataa commented 2 years ago

I 'm facing same exception

LittleYolk commented 2 years ago

when I test my code by monkey test, I face the same issue , how to solve it?

LittleYolk commented 2 years ago

I had this problem too on Desktop (Windows), but it seems to be resolved in v1.2.0-alpha01-dev741.

The version I use is v1.2.0-alpha04

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.