https://kotlinlang.org logo
#compose
Title
# compose
l

Liangjun Sha

05/06/2022, 2:58 AM
Hi, I’m trying to write a list with
LazyColumn
, there is a
ConstraintLayout
in the top of it and other items list below the
ConstraintLayout
. It works well until I changed the compose version from
1.1.1
to
1.2.0-alpha08
, and now it crashed every single time when I scroll the
LazyColumn
.
extension version and kt compiler version
Copy code
kotlinCompilerExtensionVersion 1.2.0-alpha08
kotlinCompilerVersion '1.6.20'
Here is the minimal code.
Copy code
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
    Compose20220506Theme {

        LazyColumn {
            item(key = "top") {
                ConstraintLayout {
                    val x = createRef()
                    LazyRow(Modifier.constrainAs(x) {
                        start.linkTo(parent.start)
                        end.linkTo(parent.end)
                    }) {
                        items(30) {
                            Text(
                                modifier = Modifier.padding(end = 10.dp),
                                text = it.toString()
                            )
                        }
                    }
                }
            }
            items(100) {
                MyItem(title = it.toString())
            }
        }
    }
}

@Composable
fun MyItem(title: String) {
    Text(text = title, modifier = Modifier.fillMaxWidth())
}
Copy code
java.lang.IllegalArgumentException: Inconsistency between the count of nodes tracked by the state (0) and the children count on the SubcomposeLayout (17). Are you trying to use the state of the disposed SubcomposeLayout?
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.makeSureStateIsConsistent(SubcomposeLayout.kt:514)
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:391)
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$Scope.subcompose(SubcomposeLayout.kt:715)
        at androidx.compose.foundation.lazy.layout.LazyLayoutMeasureScopeImpl.measure-0kLqBqw(LazyLayoutMeasureScope.kt:118)
        at androidx.compose.foundation.lazy.LazyMeasuredItemProvider.getAndMeasure-ZjPyQlc(LazyMeasuredItemProvider.kt:47)
        at androidx.compose.foundation.lazy.LazyListMeasureKt.measureLazyList-7Xnphek(LazyListMeasure.kt:149)
        at androidx.compose.foundation.lazy.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke-0kLqBqw(LazyList.kt:267)
        at androidx.compose.foundation.lazy.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke(LazyList.kt:195)
        at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$2$1.invoke-0kLqBqw(LazyLayout.kt:74)
        at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$2$1.invoke(LazyLayout.kt:70)
        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:581)
        at androidx.compose.ui.node.InnerPlaceable.measure-BRTryo0(InnerPlaceable.kt:44)
        at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:405)
        at androidx.compose.ui.node.ModifiedLayoutNode.measure-BRTryo0(ModifiedLayoutNode.kt:53)
        at androidx.compose.ui.node.LayoutNode$performMeasure$1.invoke(LayoutNode.kt:1388)
        at androidx.compose.ui.node.LayoutNode$performMeasure$1.invoke(LayoutNode.kt:1387)
        at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2063)
        at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:112)
        at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:78)
        at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:66)
        at androidx.compose.ui.node.LayoutNode.performMeasure-BRTryo0$ui_release(LayoutNode.kt:1387)
        at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(OuterMeasurablePlaceable.kt:94)
        at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release(LayoutNode.kt:1341)
        at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release$default(LayoutNode.kt:1337)
        at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA(MeasureAndLayoutDelegate.kt:187)
        at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:274)
        at androidx.compose.ui.node.MeasureAndLayoutDelegate.access$remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:38)
        at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:208)
        at androidx.compose.ui.platform.AndroidComposeView.measureAndLayout(AndroidComposeView.android.kt:740)
        at androidx.compose.ui.node.Owner$DefaultImpls.measureAndLayout$default(Owner.kt:196)
        at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:937)
        at android.view.View.draw(View.java:21997)
        at android.view.View.updateDisplayListIfDirty(View.java:20854)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4621)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4594)
        at android.view.View.updateDisplayListIfDirty(View.java:20812)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4621)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4594)
        at android.view.View.updateDisplayListIfDirty(View.java:20812)
2022-05-06 10:48:08.072 28579-28579/com.zyys.compose20220506 E/AndroidRuntime:     at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4621)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4594)
        at android.view.View.updateDisplayListIfDirty(View.java:20812)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4621)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4594)
        at android.view.View.updateDisplayListIfDirty(View.java:20812)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:583)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:589)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:667)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:4317)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4125)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3385)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2166)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8884)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1280)
        at android.view.Choreographer.doCallbacks(Choreographer.java:1019)
        at android.view.Choreographer.doFrame(Choreographer.java:911)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1248)
        at android.os.Handler.handleCallback(Handler.java:900)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8668)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
a

Albert Chang

05/06/2022, 3:45 AM
16 Views