Status Update
Comments
mn...@google.com <mn...@google.com>
jo...@google.com <jo...@google.com> #2
Hi, can you post a full repro case?
to...@gmail.com <to...@gmail.com> #3
I also face this and do not have yet a small repro. (But deep down in the hierarchy it looks like OP) But it started to appear after I optimized something that took a little time on main thread.
Simulating the previous delay with a Thread.sleep(250) on main thread do workaround this.
Looks like LookAhead tries to read the offset before there's even a first render, maybe something for Doris?
jo...@google.com <jo...@google.com> #4
Marking this as a duplicate of
Description
Jetpack Compose component(s) used:
all libraries + M3 version 1.2.0-alpha07
Android Studio Build: 2023.2.1 canary 3
Kotlin version: 1.9.10
Steps to Reproduce or Code Sample to Reproduce:
I haven't made a minimal sample, but I'm using SwipeToDismiss inside a lazy list.
The stack trace looks similar to
except with AnchoredDraggable instead of SwipeableV2 because of a change in the last M3 update.
I don't use the DismissState beyond creating it and using it in SwipeToDismiss.
Here's what the function looks like in my code:
```
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ColumnScope.CDSummariesList(cdSums: List<CDListingWrapper>, onDismiss: (CDListingWrapper) -> Boolean) {
LazyColumn(
modifier = Modifier
.padding(horizontal = 4.dp, vertical = 2.dp)
.weight(1f, false)
) {
items(
items = cdSums,
key = {it.legacyItemId},
itemContent = { wrapper ->
val dismissState = rememberDismissState(
initialValue = DismissValue.Default,
confirmValueChange = {
if(it == DismissValue.DismissedToEnd)
onDismiss(wrapper)
else false
},
)
SwipeToDismiss(
state = dismissState,
directions = setOf(DismissDirection.StartToEnd),
background = {},
dismissContent = {
Row {
/* basic ui elements to make a horizontal card */
}
}
)
}
)
}
}
```
Seems
Stack trace (if applicable):
```
AndroidRuntime com...lubhousexml E FATAL EXCEPTION: main
Process: com.jonolds.clubhousexml, PID: 20796
java.lang.IllegalStateException: The offset was read before being initialized. Did you access the offset in a phase before layout, like effects or composition?
at androidx.compose.material3.AnchoredDraggableState.requireOffset(AnchoredDraggable.kt:345)
at androidx.compose.material3.DismissState.requireOffset(SwipeToDismiss.kt:148)
at androidx.compose.material3.SwipeToDismissKt$SwipeToDismiss$3$1.invoke-Bjo55l4(SwipeToDismiss.kt:358)
at androidx.compose.material3.SwipeToDismissKt$SwipeToDismiss$3$1.invoke(SwipeToDismiss.kt:358)
at androidx.compose.foundation.layout.OffsetPxNode$measure$1.invoke(Offset.kt:247)
at androidx.compose.foundation.layout.OffsetPxNode$measure$1.invoke(Offset.kt:246)
at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:70)
at androidx.compose.ui.node.LookaheadDelegate.placeChildren(LookaheadDelegate.kt:178)
at androidx.compose.ui.node.LookaheadDelegate.placeAt-f8xVGno(LookaheadDelegate.kt:156)
at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:463)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:231)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$placeAt$1.invoke(LayoutNodeLayoutDelegate.kt:1288)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$placeAt$1.invoke(LayoutNodeLayoutDelegate.kt:1286)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release(OwnerSnapshotObserver.kt:96)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release$default(OwnerSnapshotObserver.kt:90)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.placeAt-f8xVGno(LayoutNodeLayoutDelegate.kt:1286)
at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:463)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:231)
at androidx.compose.foundation.layout.BoxKt.placeInBox(Box.kt:185)
at androidx.compose.foundation.layout.BoxKt.access$placeInBox(Box.kt:1)
at androidx.compose.foundation.layout.BoxKt$boxMeasurePolicy$1$5.invoke(Box.kt:166)
at androidx.compose.foundation.layout.BoxKt$boxMeasurePolicy$1$5.invoke(Box.kt:162)
at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:70)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$layoutChildren$1.invoke(LayoutNodeLayoutDelegate.kt:1064)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$layoutChildren$1.invoke(LayoutNodeLayoutDelegate.kt:1059)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:81)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release$default(OwnerSnapshotObserver.kt:75)
AndroidRuntime com...lubhousexml E at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.layoutChildren(LayoutNodeLayoutDelegate.kt:1059)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.onNodePlaced$ui_release(LayoutNodeLayoutDelegate.kt:1441)
at androidx.compose.ui.node.InnerNodeCoordinator$LookaheadDelegateImpl.placeChildren(InnerNodeCoordinator.kt:97)
at androidx.compose.ui.node.LookaheadDelegate.placeAt-f8xVGno(LookaheadDelegate.kt:156)
at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:463)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:231)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$placeAt$1.invoke(LayoutNodeLayoutDelegate.kt:1288)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$placeAt$1.invoke(LayoutNodeLayoutDelegate.kt:1286)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release(OwnerSnapshotObserver.kt:96)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release$default(OwnerSnapshotObserver.kt:90)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.placeAt-f8xVGno(LayoutNodeLayoutDelegate.kt:1286)
at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer-aW-9-wM(Placeable.kt:489)
at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer-aW-9-wM$default(Placeable.kt:320)
at androidx.compose.foundation.lazy.LazyListMeasuredItem.place(LazyListMeasuredItem.kt:182)
at androidx.compose.foundation.lazy.LazyListMeasureKt$measureLazyList$8.invoke(LazyListMeasure.kt:352)
at androidx.compose.foundation.lazy.LazyListMeasureKt$measureLazyList$8.invoke(LazyListMeasure.kt:349)
at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:70)
at androidx.compose.foundation.lazy.LazyListMeasureResult.placeChildren(Unknown Source:2)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1$measure-3p2s80s$$inlined$createMeasureResult$2.placeChildren(SubcomposeLayout.kt:951)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$layoutChildren$1.invoke(LayoutNodeLayoutDelegate.kt:1064)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$layoutChildren$1.invoke(LayoutNodeLayoutDelegate.kt:1059)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:81)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release$default(OwnerSnapshotObserver.kt:75)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.layoutChildren(LayoutNodeLayoutDelegate.kt:1059)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.onNodePlaced$ui_release(LayoutNodeLayoutDelegate.kt:1441)
at androidx.compose.ui.node.InnerNodeCoordinator$LookaheadDelegateImpl.placeChildren(InnerNodeCoordinator.kt:97)
AndroidRuntime com...lubhousexml E at androidx.compose.ui.node.LookaheadDelegate.placeAt-f8xVGno(LookaheadDelegate.kt:156)
at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer(Placeable.kt:486)
at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer$default(Placeable.kt:299)
at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier$measure$1.invoke(GraphicsLayerModifier.kt:648)
at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier$measure$1.invoke(GraphicsLayerModifier.kt:647)
at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:70)
at androidx.compose.ui.node.LookaheadDelegate.placeChildren(LookaheadDelegate.kt:178)
at androidx.compose.ui.node.LookaheadDelegate.placeAt-f8xVGno(LookaheadDelegate.kt:156)
at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelative(Placeable.kt:452)
at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelative$default(Placeable.kt:204)
at androidx.compose.foundation.layout.PaddingNode$measure$1.invoke(Padding.kt:403)
at androidx.compose.foundation.layout.PaddingNode$measure$1.invoke(Padding.kt:401)
at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:70)
at androidx.compose.ui.node.LookaheadDelegate.placeChildren(LookaheadDelegate.kt:178)
at androidx.compose.ui.node.LookaheadDelegate.placeAt-f8xVGno(LookaheadDelegate.kt:156)
at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:463)
at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:231)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$placeAt$1.invoke(LayoutNodeLayoutDelegate.kt:1288)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate$placeAt$1.invoke(LayoutNodeLayoutDelegate.kt:1286)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release(OwnerSnapshotObserver.kt:96)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release$default(OwnerSnapshotObserver.kt:90)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.placeAt-f8xVGno(LayoutNodeLayoutDelegate.kt:1286)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$LookaheadPassDelegate.replace(LayoutNodeLayoutDelegate.kt:1523)
at androidx.compose.ui.node.LayoutNode.lookaheadReplace$ui_release(LayoutNode.kt:926)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:486)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded$default(MeasureAndLayoutDelegate.kt:461)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:354)
at androidx.compose.ui.platform.AndroidComposeView.measureAndLayout(AndroidComposeView.android.kt:937)
at androidx.compose.ui.node.Owner.measureAndLayout$default(Owner.kt:230)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:1186)
at android.view.View.draw(View.java:22538)
at android.view.View.updateDisplayListIfDirty(View.java:21389)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4525)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4498)
at android.view.View.updateDisplayListIfDirty(View.java:21349)
AndroidRuntime com...lubhousexml E at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4525)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4498)
at android.view.View.updateDisplayListIfDirty(View.java:21349)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4525)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4498)
at android.view.View.updateDisplayListIfDirty(View.java:21349)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4525)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4498)
at android.view.View.updateDisplayListIfDirty(View.java:21349)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:559)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:565)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:647)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4448)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4175)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3422)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2206)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8763)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1352)
at android.view.Choreographer.doCallbacks(Choreographer.java:1149)
at android.view.Choreographer.doFrame(Choreographer.java:1049)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1333)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:233)
at android.app.ActivityThread.main(ActivityThread.java:8068)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
```