Starting again to get some `layout state is not id...
# compose
t
Starting again to get some
layout state is not idle before measure starts
crashes with Compose 1.10 alpha 1. Last time it was some obscure bug with viewpager found by luck. Would it be possible for Compose to log the actual state it is in for that crash to help? Or is there anything I could log about current state if i was to catch the measure issue in the Layout ?
s
I had a similar crash caused by movable content in the latest alpha, it is now fixed. The exact message, however, is similar to the circumstances of "pending composition not applied". It basically means that we tried to measure something in a coroutine, crashed, remeasured again from the framework call and crashed with this message. So tldr; you are seeing a crash that might not actually be the problem here.
You can use debug stack trace if the crash is reproducible locally to point you to a problematic layout (see Composer.setDiagnosticStackTraceEnabled)
t
Thanks, unfortunately that's the usual rare not reproducible crashes. I've seen the new diag stuff it's nice. Do you have a link for the fix ? Will it be in alpha 2 or should I go to snapshots ?
s
I think it should be in alpha02
👍 1
t
Just got a different crash report on the same layout:
Copy code
Fatal Exception: java.lang.IndexOutOfBoundsException: Index 1, size 1
       at androidx.compose.foundation.internal.InlineClassHelperKt.throwIndexOutOfBoundsException(InlineClassHelper.kt:42)
       at androidx.compose.foundation.lazy.layout.MutableIntervalList.get(MutableIntervalList.java:227)
       at androidx.compose.foundation.lazy.layout.LazyLayoutIntervalContent.getKey(LazyLayoutIntervalContent.java:73)
       at androidx.compose.foundation.pager.PagerLazyLayoutItemProvider.getKey(LazyLayoutPager.kt:219)
       at androidx.compose.foundation.lazy.layout.LazyLayoutMeasureScopeImpl.compose(LazyLayoutMeasureScope.kt:91)
       at androidx.compose.foundation.pager.PagerMeasurePolicyKt.keepAroundItems(PagerMeasurePolicy.kt:259)
       at androidx.compose.foundation.pager.PagerMeasurePolicyKt.access$keepAroundItems(PagerMeasurePolicy.kt:1)
       at androidx.compose.foundation.pager.PagerMeasurePolicyKt$rememberPagerMeasurePolicy$1$1.measure-0kLqBqw(PagerMeasurePolicy.kt:229)
       at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$2.invoke$lambda$8$lambda$7(LazyLayout.kt:141)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:949)
       at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:128)
       at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:843)
       at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:190)
       at androidx.compose.foundation.lazy.layout.LazyLayoutBeyondBoundsModifierNode.measure-3p2s80s(LazyLayoutBeyondBoundsModifierLocal.kt:118)
       at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:190)
       at androidx.compose.foundation.layout.FillNode.measure-3p2s80s(Size.kt:721)
       at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:190)
       at androidx.compose.ui.node.MeasurePassDelegate$performMeasureBlock$1.invoke(MeasurePassDelegate.kt:173)
       at androidx.compose.ui.node.MeasurePassDelegate$performMeasureBlock$1.invoke(MeasurePassDelegate.kt:172)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:689)
       at androidx.compose.ui.node.MeasurePassDelegate.remeasure-BRTryo0(MeasurePassDelegate.kt:1034)
       at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui(LayoutNode.kt:1302)
       at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui$default(LayoutNode.kt:1295)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA(MeasureAndLayoutDelegate.java:380)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.java:595)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.onlyRemeasureIfPending(MeasureAndLayoutDelegate.java:689)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.forceMeasureTheSubtreeInternal(MeasureAndLayoutDelegate.java:716)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.forceMeasureTheSubtree(MeasureAndLayoutDelegate.java:680)
       at androidx.compose.ui.platform.AndroidComposeView.forceMeasureTheSubtree(AndroidComposeView.android.kt:1862)
       at androidx.compose.ui.node.Owner.forceMeasureTheSubtree$default(Owner.kt:256)
       at androidx.compose.ui.node.MeasurePassDelegate.remeasure-BRTryo0(MeasurePassDelegate.kt:490)
       at androidx.compose.ui.node.MeasurePassDelegate.measure-BRTryo0(MeasurePassDelegate.kt:452)
       at app.symfonik.ui.playback.components.expanded.PortraitPlayerLayoutKt$PortraitPlayerLayout$5$1.measure-3p2s80s(PortraitPlayerLayout.kt:71)
Does it sound related to your fix or should I really try to find a way for the users to contact me for a repro ?
s
This is probably related to updating the state from another thread which does not work well with measure because it is not snapshot isolated There's a workaround that does:
Copy code
Modifier.layout { m, c ->
  withMutableSnapshot {
    m.measure(c)
  }
  ...
}
t
Thanks, long ago with the previous similar crash (first one) I made sure to be thread safe on all updates there and nothing have changed except 1.9 to 1.10. This is currently on my beta builds so can wait alpha 2 and try to investigate more.