LazyColumn always crash the crash log is : 2023-0...
# compose-android
u
LazyColumn always crash the crash log is : 2023-01-01 000044.678 707-707 AndroidRuntime tech.autra.auto D Shutting down VM 2023-01-01 000044.680 707-707 AndroidRuntime tech.autra.auto E FATAL EXCEPTION: main Process: tech.autra.auto, PID: 707 java.lang.IndexOutOfBoundsException: index: 0, size: 0 at androidx.compose.runtime.external.kotlinx.collections.immutable.internal.ListImplementation.checkElementIndex$runtime_release(ListImplementation.kt:15) at androidx.compose.runtime.external.kotlinx.collections.immutable.implementations.immutableList.SmallPersistentVector.get(SmallPersistentVector.kt:146) at androidx.compose.runtime.snapshots.SnapshotStateList.get(SnapshotStateList.kt:89) at tech.autra.auto.ui.TextNotiCardKt$TextNotiCardList$2$1$invoke$$inlined$itemsIndexed$default$2.invoke(LazyDsl.kt:179) at tech.autra.auto.ui.TextNotiCardKt$TextNotiCardList$2$1$invoke$$inlined$itemsIndexed$default$2.invoke(LazyDsl.kt:176) at androidx.compose.foundation.lazy.layout.LazyLayoutIntervalContent.getContentType(LazyLayoutIntervalContent.kt:46) at androidx.compose.foundation.lazy.LazyListItemProviderImpl.getContentType(LazyListItemProvider.kt:87) at androidx.compose.foundation.lazy.LazyListMeasuredItemProvider.getAndMeasure(LazyListMeasuredItemProvider.kt:47) at androidx.compose.foundation.lazy.LazyListMeasureKt.measureLazyList-CD5nmq0(LazyListMeasure.kt:159) at androidx.compose.foundation.lazy.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke-0kLqBqw(LazyList.kt:306) at androidx.compose.foundation.lazy.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke(LazyList.kt:184) at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke-0kLqBqw(LazyLayout.kt:87) at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke(LazyLayout.kt:80) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:866) at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:126) at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure- 3p2s80s(GraphicsLayerModifier.kt:646) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:116) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1499) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1495) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2299) at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:467) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:230) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133) at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113) And the code is
Copy code
@Composable
fun TextNotiCardList(textNotiState: SnapshotStateList<ATextNotification>) {
    Timber.tag("TextNotiCardList").e("TextNotiCardList->${textNotiState.toList()}")
    if (textNotiState.isEmpty()) {
        return
    }

    LazyColumn(
        verticalArrangement = Arrangement.Top,
        horizontalAlignment = Alignment.CenterHorizontally,
    ){
        itemsIndexed(items = textNotiState) { index, item ->
            TextNotiCard(text = item.textNoti.messageZh, level = item.textNoti.level)
            Spacer(modifier = Modifier.height(10.dp))
        }
    }
}
🧵 10
l
Please @王欢, edit your message and move the large snippet + error stuff in this thread, properly formatted, as per the Code of Conduct of this Slack.
@王欢 ☝️
a
what is the version of compose you are using? also are you updating your SnapshotStateList on main thread?
u
Sorry already fix the problem
thanks