Fixed
Status Update
Comments
st...@google.com <st...@google.com>
lo...@gmail.com <lo...@gmail.com> #2
There's some code in the tracers:
com.swissborg.app.common.compose.navigation.NavigationAnimationsKt$offsetXFactor$1 in invoke-3p2s80s at line 24
com.swissborg.app.common.compose.navigation.NavigationAnimationsKt$offsetXFactor$1 in invoke at line 23
Woudl you be able to link it or provide a similar code to what you have to help us debug further? How offsetXFactor looks like as well as your custom navigation logic and how it swaps the screens
an...@google.com <an...@google.com> #3
this is how offsetXFactor looks like:
```
private fun Modifier.offsetXFactor(
offsetX: (fullWidth: Int) -> Int,
factor: Float,
): Modifier = layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
layout(placeable.width, placeable.height) {
placeable.placeRelative(
x = lerp(0f, offsetX(placeable.width).toFloat(), factor).toInt(),
y = 0,
)
}
}
```
and this is how we swap the screens:
```
fun slideHorizontally(
offsetX: (fullWidth: Int) -> Int,
animationSpec: FiniteAnimationSpec<Float> = tween(),
): StackAnimator = stackAnimator(animationSpec = animationSpec) { factor, _, content ->
content(Modifier.offsetXFactor(offsetX, factor))
}
```
we use different enter/exit transition animations, i.e.
```
open fun enterTransition(): StackAnimator = slideHorizontally(
offsetX = { it },
animationSpec = tween(ScreenTransitionAnimationDuration),
)
```
```
private fun Modifier.offsetXFactor(
offsetX: (fullWidth: Int) -> Int,
factor: Float,
): Modifier = layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
layout(placeable.width, placeable.height) {
placeable.placeRelative(
x = lerp(0f, offsetX(placeable.width).toFloat(), factor).toInt(),
y = 0,
)
}
}
```
and this is how we swap the screens:
```
fun slideHorizontally(
offsetX: (fullWidth: Int) -> Int,
animationSpec: FiniteAnimationSpec<Float> = tween(),
): StackAnimator = stackAnimator(animationSpec = animationSpec) { factor, _, content ->
content(Modifier.offsetXFactor(offsetX, factor))
}
```
we use different enter/exit transition animations, i.e.
```
open fun enterTransition(): StackAnimator = slideHorizontally(
offsetX = { it },
animationSpec = tween(ScreenTransitionAnimationDuration),
)
```
lo...@gmail.com <lo...@gmail.com> #4
I found the same error while working for my current company and it was caused by a missing CompositionLocal. In my case, I wasn't using the app theme and the error was not explicit at all with that missing implicit dependency. May that be your same case?
an...@google.com <an...@google.com> #5
After updating the libraries the error eventually went away. It's ok to close this issue now
lo...@gmail.com <lo...@gmail.com> #6
What libraries did you update? The Compose BOM or any other libraries in the process?
ap...@google.com <ap...@google.com> #7
We've updated Compose BOM, but it introduced other compose bug : lookahead pass was never done for target content
na...@google.com <na...@google.com> #8
This has been happening for us for longtime already, happens randomly on for few users
compose-bom = "2023.10.01"
Exception java.lang.IllegalArgumentException: Cannot round NaN value.
at kotlin.math.MathKt__MathJVMKt.roundToInt (MathJVM.kt:1165)
at androidx.compose.material3.AppBarKt$TopAppBarLayout$2.measure-3p2s80s (AppBar.kt:1361)
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.foundation.layout.InsetsPaddingModifier.measure-3p2s80s (WindowInsetsPadding.kt:171)
at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s (BackwardsCompatNode.kt:311)
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.enter (Snapshot.java:131)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe (Snapshot.kt:476)
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)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0 (LayoutNodeLayoutDelegate.java:1495)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0 (LayoutNodeLayoutDelegate.java:35)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0 (LayoutNodeLayoutDelegate.kt:560)
at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release (LayoutNode.kt:1140)
at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release$default (LayoutNode.kt:1131)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA (MeasureAndLayoutDelegate.kt:323)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded (MeasureAndLayoutDelegate.kt:458)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.access$getRoot$p (MeasureAndLayoutDelegate.kt:39)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.access$remeasureAndRelayoutIfNeeded (MeasureAndLayoutDelegate.kt:39)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout (MeasureAndLayoutDelegate.kt:344)
at androidx.compose.ui.platform.AndroidComposeView.measureAndLayout (AndroidComposeView.android.kt:879)
at androidx.compose.ui.platform.AndroidComposeView.<init> (AndroidComposeView.android.kt:223)
at androidx.compose.ui.node.Owner.measureAndLayout$default (Owner.java:223)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw (AndroidComposeView.android.kt:1127)
at android.view.View.draw (View.java:19317)
at android.view.View.updateDisplayListIfDirty (View.java:18250)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ThreadedRenderer.updateViewTreeDisplayList (ThreadedRenderer.java:684)
at android.view.ThreadedRenderer.updateRootDisplayList (ThreadedRenderer.java:690)
at android.view.ThreadedRenderer.draw (ThreadedRenderer.java:804)
at android.view.ViewRootImpl.draw (ViewRootImpl.java:3206)
at android.view.ViewRootImpl.performDraw (ViewRootImpl.java:3004)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2533)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1522)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7292)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:981)
at android.view.Choreographer.doCallbacks (Choreographer.java:790)
at android.view.Choreographer.doFrame (Choreographer.java:721)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:967)
at android.os.Handler.handleCallback (Handler.java:808)
at android.os.Handler.dispatchMessage (Handler.java:101)
at android.os.Looper.loop (Looper.java:166)
at android.app.ActivityThread.main (ActivityThread.java:7529)
at java.lang.reflect.Method.invoke
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)
compose-bom = "2023.10.01"
Exception java.lang.IllegalArgumentException: Cannot round NaN value.
at kotlin.math.MathKt__MathJVMKt.roundToInt (MathJVM.kt:1165)
at androidx.compose.material3.AppBarKt$TopAppBarLayout$2.measure-3p2s80s (AppBar.kt:1361)
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.foundation.layout.InsetsPaddingModifier.measure-3p2s80s (WindowInsetsPadding.kt:171)
at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s (BackwardsCompatNode.kt:311)
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.enter (Snapshot.java:131)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe (Snapshot.kt:476)
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)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0 (LayoutNodeLayoutDelegate.java:1495)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0 (LayoutNodeLayoutDelegate.java:35)
at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0 (LayoutNodeLayoutDelegate.kt:560)
at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release (LayoutNode.kt:1140)
at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release$default (LayoutNode.kt:1131)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA (MeasureAndLayoutDelegate.kt:323)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded (MeasureAndLayoutDelegate.kt:458)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.access$getRoot$p (MeasureAndLayoutDelegate.kt:39)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.access$remeasureAndRelayoutIfNeeded (MeasureAndLayoutDelegate.kt:39)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout (MeasureAndLayoutDelegate.kt:344)
at androidx.compose.ui.platform.AndroidComposeView.measureAndLayout (AndroidComposeView.android.kt:879)
at androidx.compose.ui.platform.AndroidComposeView.<init> (AndroidComposeView.android.kt:223)
at androidx.compose.ui.node.Owner.measureAndLayout$default (Owner.java:223)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw (AndroidComposeView.android.kt:1127)
at android.view.View.draw (View.java:19317)
at android.view.View.updateDisplayListIfDirty (View.java:18250)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4252)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4232)
at android.view.View.updateDisplayListIfDirty (View.java:18209)
at android.view.ThreadedRenderer.updateViewTreeDisplayList (ThreadedRenderer.java:684)
at android.view.ThreadedRenderer.updateRootDisplayList (ThreadedRenderer.java:690)
at android.view.ThreadedRenderer.draw (ThreadedRenderer.java:804)
at android.view.ViewRootImpl.draw (ViewRootImpl.java:3206)
at android.view.ViewRootImpl.performDraw (ViewRootImpl.java:3004)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2533)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1522)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7292)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:981)
at android.view.Choreographer.doCallbacks (Choreographer.java:790)
at android.view.Choreographer.doFrame (Choreographer.java:721)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:967)
at android.os.Handler.handleCallback (Handler.java:808)
at android.os.Handler.dispatchMessage (Handler.java:101)
at android.os.Looper.loop (Looper.java:166)
at android.app.ActivityThread.main (ActivityThread.java:7529)
at java.lang.reflect.Method.invoke
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)
ch...@gmail.com <ch...@gmail.com> #9
Unfortunately after updating to newer compose it is back with quite a few crashes ( compose-bom:2023.12.00-alpha03 )
an...@google.com <an...@google.com> #10
same with compose-bom = "2024.02.00"
ch...@gmail.com <ch...@gmail.com> #11
looks like downgrading from 2.8.0 alpha to 2.7.0 for "androidx.lifecycle:lifecycle-viewmodel-compose" library might have fixed our issues with "Lookahead pass was never done for target content" and "Cannot round NaN value".
an...@google.com <an...@google.com> #12
Project: platform/frameworks/support
Branch: androidx-main
commit f51389603b0fdfe2534dd7249b7b4f027ba08919
Author: Faithful Uchenna Okoye <uokoye@google.com>
Date: Tue Mar 26 21:03:38 2024
Add Debugging logs for hard-to-reproduce bugs
Bug: 300280216
Bug: 297974033
Test: Existing tests passing
Change-Id: Ic49d51a7801dc6b02fe5b8e2fc62dca947028658
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/RowColumnMeasurePolicy.kt
https://android-review.googlesource.com/3015316
Branch: androidx-main
commit f51389603b0fdfe2534dd7249b7b4f027ba08919
Author: Faithful Uchenna Okoye <uokoye@google.com>
Date: Tue Mar 26 21:03:38 2024
Add Debugging logs for hard-to-reproduce bugs
Bug: 300280216
Bug: 297974033
Test: Existing tests passing
Change-Id: Ic49d51a7801dc6b02fe5b8e2fc62dca947028658
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/RowColumnMeasurePolicy.kt
ch...@gmail.com <ch...@gmail.com> #13
Project: platform/frameworks/support
Branch: androidx-main
commit 881db4641c4c3088c4b559d19831255ed94e1b8a
Author: Faithful Uchenna Okoye <uokoye@google.com>
Date: Fri Mar 29 08:24:08 2024
Modified debugging logs with additional details
Bug: 300280216
Bug: 297974033
Test: Existing tests passing
Change-Id: I0a08f2b7b09bfee064ace2a6efb29c0244b5da22
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/RowColumnMeasurePolicy.kt
https://android-review.googlesource.com/3018495
Branch: androidx-main
commit 881db4641c4c3088c4b559d19831255ed94e1b8a
Author: Faithful Uchenna Okoye <uokoye@google.com>
Date: Fri Mar 29 08:24:08 2024
Modified debugging logs with additional details
Bug: 300280216
Bug: 297974033
Test: Existing tests passing
Change-Id: I0a08f2b7b09bfee064ace2a6efb29c0244b5da22
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/RowColumnMeasurePolicy.kt
an...@google.com <an...@google.com> #14
+1 on this as I've seen a spike when bumping to Compose 1.6.x, wild guess here but I think in my case is that due to SwipeToDismiss
L198-L221 in androidx.compose.material:material:1.6.2
:
Box(
Modifier.swipeable(
state = state,
anchors = anchors,
thresholds = thresholds,
orientation = Orientation.Horizontal,
enabled = state.currentValue == Default,
reverseDirection = isRtl,
resistance = ResistanceConfig(
basis = width,
factorAtMin = minFactor,
factorAtMax = maxFactor
)
)
) {
Row(
content = background,
modifier = Modifier.matchParentSize()
)
Row(
content = dismissContent,
modifier = Modifier.offset { IntOffset(state.offset.value.roundToInt(), 0) } // <---- state.offset.value can be NaN?
)
}
Crashes only occur in screens where I have SwipeToDismiss
components, so that's my main guess and only on Android 9 and 10.
pr...@google.com <pr...@google.com> #15
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation-layout:1.7.0-alpha07
androidx.compose.foundation:foundation-layout-android:1.7.0-alpha07
androidx.compose.foundation:foundation-layout-desktop:1.7.0-alpha07
Description
1) Via composition local to find a parent pinnable parent
2) Call pin on it, which means that this composable will be kept composed even if it will naturally be scrolled our of the viewport of this pinnable parent
3) To be defined if we need to place such layoutnode or not. Probably we should, we can try to first pin it at some fake position outside the viewbounds
4) There should be a possibility to unpin it when the pinning is not needed anymore (for example the item is not focused anymore)
5) Such logic should work for nested lazy lists recursively, for example for cases when we have focused item inside LazyRow inside LazyColumn
6) Eventually the code should be abstracted away so it is easy to add such logic into your own LazyLayout implementation, for the first implementation we can just add it in LazyColumn as an internal api