jherkenhoff / qalculate-android

Powerful and versatile multi-purpose calculator for the Android platform
GNU General Public License v2.0
65 stars 4 forks source link

Crash when typing too fast #67

Closed ByteHamster closed 4 hours ago

ByteHamster commented 4 hours ago

Mostly happens when typing nonsense, but should probably still be investigated because it makes users lose the text they already entered.

FATAL EXCEPTION: main
Process: com.jherkenhoff.qalculate, PID: 18377
java.lang.IllegalStateException: Nothing to pop.
    at androidx.compose.ui.text.AnnotatedString$Builder.pop(AnnotatedString.kt:712)
    at com.jherkenhoff.qalculate.ui.calculator.MathExpressionFormattedKt.mathExpressionFormatted(mathExpressionFormatted.kt:28)
    at com.jherkenhoff.qalculate.ui.calculator.CalculationListItemKt.CalculationListItem(CalculationListItem.kt:37)
    at com.jherkenhoff.qalculate.ui.calculator.CalculationListItemKt.CalculationListItem(CalculationListItem.kt:59)
    at com.jherkenhoff.qalculate.ui.calculator.CalculationListKt$CalculationList$1$1$1$3.invoke(CalculationList.kt:88)
    at com.jherkenhoff.qalculate.ui.calculator.CalculationListKt$CalculationList$1$1$1$3.invoke(CalculationList.kt:87)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:118)
    at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jvm.kt:130)
    at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jvm.kt:129)
    at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:192)
    at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2825)
    at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3116)
    at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3607)
    at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3552)
    at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:948)
    at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1206)
    at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:132)
    at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:616)
    at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:585)
    at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:41)
    at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
    at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
    at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1404)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1415)
    at android.view.Choreographer.doCallbacks(Choreographer.java:1015)
    at android.view.Choreographer.doFrame(Choreographer.java:941)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1389)
    at android.os.Handler.handleCallback(Handler.java:959)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8592)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@defe490, androidx.compose.ui.platform.MotionDurationScaleImpl@e286189, StandaloneCoroutine{Cancelling}@ddf758e, AndroidUiDispatcher@7ca81af]
jherkenhoff commented 4 hours ago

Good spot! Thanks for bringing that up! I did miss to parse an upstream libqalculate color that is used by the internal formatter to indicate "undefined". Thats why it probably only occurred when typing nonsense, but now it should be fixed.

Actually, typing undefined into the input bar crashed the app deterministically, which is now fixed in the main branch.