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.25k stars 1.18k forks source link

Textfield ArrayIndexOutOfBoundsException crash #4448

Closed brendanw closed 8 months ago

brendanw commented 8 months ago

Describe the bug Seeing the below ArrayIndexOutOfBoundsException show up for 1 user in Bugsnag:

kotlin.ArrayIndexOutOfBoundsException: 

0  BaseBetaiOS +0x4db1c     kfun:kotlin.Throwable#<init>(){} (Throwable.kt:32:21)
1  BaseBetaiOS +0xd553bc    Kotlin_String_get
2  BaseBetaiOS +0x56a20c    kfun:androidx.compose.foundation.text#codePointAt__at__kotlin.CharSequence(kotlin.Int){}kotlin.Int (StringHelpers.skiko.kt:70:16)
3  BaseBetaiOS +0x568554    kfun:androidx.compose.foundation.text#findNextNonWhitespaceSymbolsSubsequenceStartOffset(kotlin.Int;kotlin.String){}kotlin.Int (StringHelpers.skiko.kt:126:83)
4  BaseBetaiOS +0x8f8978    kfun:kotlin.Function1#invoke(1:0){}1:1-trampoline ([K][Suspend]Functions:1:1)
5  BaseBetaiOS +0x56611c    kfun:androidx.compose.foundation.gestures.$detectRepeatingTapGestures$lambda$0COROUTINE$0.invokeSuspend#internal (TapGesturesDetector.skiko.kt)
6  BaseBetaiOS +0x3ae58     kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any?-trampoline (ContinuationImpl.kt:50:24)
7  BaseBetaiOS +0xf1f54     kfun:kotlinx.coroutines#resume__at__kotlinx.coroutines.DispatchedTask<0:0>(kotlin.coroutines.Continuation<0:0>;kotlin.Boolean){0§<kotlin.Any?>} (DispatchedTask.kt)
8  BaseBetaiOS +0xbdc40     kfun:kotlinx.coroutines#dispatch__at__kotlinx.coroutines.DispatchedTask<0:0>(kotlin.Int){0§<kotlin.Any?>} (DispatchedTask.kt:164:9)
9  BaseBetaiOS +0xbe158     <inlined-out:<anonymous>> (CancellableContinuationImpl.kt:504:21)
10 BaseBetaiOS +0xbd2bc     kfun:kotlinx.coroutines.CancellableContinuationImpl#resumeImpl$default(kotlin.Any?;kotlin.Int;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?;kotlin.Int){} (CancellableContinuationImpl.kt:493:13)
11 BaseBetaiOS +0x3ac3d0    <inlined-out:resume> (Continuation.kt:45:5)
12 BaseBetaiOS +0x3ab200    <inlined-out:<anonymous>> (SuspendingPointerInputFilter.kt:549:16)
13 BaseBetaiOS +0x3ab4cc    kfun:androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl#onPointerEvent(androidx.compose.ui.input.pointer.PointerEvent;androidx.compose.ui.input.pointer.PointerEventPass;androidx.compose.ui.unit.IntSize){} (SuspendingPointerInputFilter.kt:571:9)
14 BaseBetaiOS +0x3a4560    <inlined-out:<anonymous>> (HitPathTracker.kt:326:24)
15 BaseBetaiOS +0x3a44cc    <inlined-out:<anonymous>> (HitPathTracker.kt:312:24)
16 BaseBetaiOS +0x3a44cc    <inlined-out:<anonymous>> (HitPathTracker.kt:312:24)
17 BaseBetaiOS +0x3a44cc    <inlined-out:<anonymous>> (HitPathTracker.kt:312:24)
18 BaseBetaiOS +0x3a44cc    <inlined-out:<anonymous>> (HitPathTracker.kt:312:24)
19 BaseBetaiOS +0x3a3a08    <inlined-out:<anonymous>> (HitPathTracker.kt:187:29)
20 BaseBetaiOS +0x40f13c    kfun:androidx.compose.ui.input.pointer.NodeParent#dispatchMainEventPass(androidx.collection.LongSparseArray<androidx.compose.ui.input.pointer.PointerInputChange>;androidx.compose.ui.layout.LayoutCoordinates;androidx.compose.ui.input.pointer.InternalPointerEvent;kotlin.Boolean){}kotlin.Boolean-trampoline (HitPathTracker.kt:179:10)
21 BaseBetaiOS +0x422ff4    kfun:androidx.compose.ui.scene.SingleLayerComposeSceneImpl.processPointerInputEvent#internal (SingleLayerComposeScene.skiko.kt:162:19)
22 BaseBetaiOS +0x41aa94    kfun:androidx.compose.ui.scene.BaseComposeScene#processPointerInputEvent(androidx.compose.ui.input.pointer.PointerInputEvent){}-trampoline (BaseComposeScene.skiko.kt:230:24)
23 BaseBetaiOS +0x8f8978    kfun:kotlin.Function1#invoke(1:0){}1:1-trampoline ([K][Suspend]Functions:1:1)
24 BaseBetaiOS +0x40c4f8    kfun:androidx.compose.ui.input.pointer.SyntheticEventSender.sendInternal#internal (SyntheticEventSender.skiko.kt:175:9)
25 BaseBetaiOS +0x41b940    kfun:androidx.compose.ui.input.pointer.SyntheticEventSender#send(androidx.compose.ui.input.pointer.PointerInputEvent){} (SyntheticEventSender.skiko.kt:79:9)
26 BaseBetaiOS +0x41a658    <inlined-out:<anonymous>> (BaseComposeScene.skiko.kt:207:22)
27 BaseBetaiOS +0x44dfb4    kfun:androidx.compose.ui.scene.ComposeScene#sendPointerEvent(androidx.compose.ui.input.pointer.PointerEventType;kotlin.collections.List<androidx.compose.ui.scene.ComposeScenePointer>;androidx.compose.ui.input.pointer.PointerButtons;androidx.compose.ui.input.pointer.PointerKeyboardModifiers;androidx.compose.ui.geometry.Offset;kotlin.Long;kotlin.Any?;androidx.compose.ui.input.pointer.PointerButton?){}-trampoline (ComposeScene.skiko.kt:212:5)
28 BaseBetaiOS +0x462510    <inlined-out:<anonymous>> (InteractionUIView.uikit.kt:96:29)
29 BaseBetaiOS +0xd22774    _6f72672e6a6574627261696e732e636f6d706f73652e75693a75692f6f70742f6275696c644167656e742f776f726b2f383339343731666333323931333563372f636f6d706f73652f75692f75692f7372632f75696b69744d61696e2f6b6f746c696e2f616e64726f6964782f636f6d706f73652f75692f77696e646f772f496e746572616374696f6e5549566965772e75696b69742e6b74_kncfun45
30 UIKitCore +0xee8f8       -[UIWindow _sendTouchesForEvent:]
31 UIKitCore +0xede28       -[UIWindow sendEvent:]
32 UIKitCore +0xed114       -[UIApplication sendEvent:]
33 UIKitCore +0xeb388       ___dispatchPreprocessedEventFromEventQueue
34 UIKitCore +0x130d54      ___processEventQueue
35 UIKitCore +0x4110d0      ___eventFetcherSourceCallback
36 CoreFoundation +0xc90e4  ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
37 CoreFoundation +0xd4d58  ___CFRunLoopDoSource0
38 CoreFoundation +0x5ffc0  ___CFRunLoopDoSources0
39 CoreFoundation +0x75134  ___CFRunLoopRun
40 CoreFoundation +0x79d1c  _CFRunLoopRunSpecific
41 GraphicsServices +0x1994 _GSEventRunModal
42 UIKitCore +0x371808      -[UIApplication _run]
43 UIKitCore +0x371480      _UIApplicationMain
44 BaseBetaiOS +0xcef4      main (AppDelegate.swift:15:7)
45 dyld +0x14340            start

Affected platforms

Versions

To Reproduce I have not been able to reproduce; I suspect the issue is device-specific. The crash takes place on our login screen which is fairly simple. Here is the verbatim TextField usage:

         TextField(
            label = { Text("Email") },
            value = model.loginEmail.value,
            modifier = Modifier.fillMaxWidth(),
            onValueChange = { model.loginEmail.value = it },
            colors = authTextFieldColors()
         )

         Spacer(modifier = Modifier.height(40.dp))

         TextField(
            label = { Text("Password") },
            value = model.password.value,
            modifier = Modifier.fillMaxWidth(),
            visualTransformation = PasswordVisualTransformation(),
            keyboardOptions = KeyboardOptions(
               autoCorrect = false,
               keyboardType = KeyboardType.Password
            ),
            onValueChange = { model.password.value = it },
            colors = authTextFieldColors()
         )

Expected behavior No crash.

igordmn commented 8 months ago

Should be fixed in 1.6.1 (by https://github.com/JetBrains/compose-multiplatform-core/pull/1151).

It will be soon, in 1-2 weeks

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.