Closed Bug 2032117 Opened 7 months ago Closed 7 months ago

Compose crash: scrollToItem triggered during layout causes re-entrant measure

Categories

(Firefox for Android :: Tabs, defect)

All
Android
defect

Tracking

()

RESOLVED FIXED
151 Branch
Tracking Status
firefox149 --- unaffected
firefox150 --- unaffected
firefox151 --- fixed

People

(Reporter: aaronmt, Unassigned)

References

(Regression)

Details

(Keywords: crash, regression, ui-test-bug-auto-found)

Build: v151 [autoland/central]
Matrix: link

Logs:

TabLayoutScrollHelper calls scrollToItem from snapshotFlow during layout, leading to a re-entrant measure/layout and crashes in UI tests.

Can scrollToItem be deferred so it runs after layout completes?

Seems to mostly affect among a few others:

  • privateTabsDoNotPersistAfterClosingAppTest
  • openMultipleRecentlyClosedTabsTest
java.lang.IllegalArgumentException: performMeasureAndLayout called during measure layout
	at androidx.compose.ui.internal.InlineClassHelperKt.throwIllegalArgumentException(InlineClassHelper.kt:36)
	at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout-0kLqBqw(MeasureAndLayoutDelegate.kt:919)
	at androidx.compose.ui.platform.AndroidComposeView.measureAndLayout-0kLqBqw(AndroidComposeView.android.kt:1747)
	at androidx.compose.ui.node.LayoutNode.forceRemeasure(LayoutNode.kt:1356)
	at androidx.compose.foundation.lazy.grid.LazyGridState.snapToItemIndexInternal$foundation(LazyGridState.kt:477)
	at androidx.compose.foundation.lazy.grid.LazyGridState$scrollToItem$2.invokeSuspend(LazyGridState.kt:429)
	at androidx.compose.foundation.lazy.grid.LazyGridState$scrollToItem$2.invoke(Unknown Source:8)
	at androidx.compose.foundation.lazy.grid.LazyGridState$scrollToItem$2.invoke(Unknown Source:4)
	at androidx.compose.foundation.gestures.DefaultScrollableState$scroll$2$1.invokeSuspend(ScrollableState.kt:211)
	at androidx.compose.foundation.gestures.DefaultScrollableState$scroll$2$1.invoke(Unknown Source:8)
	at androidx.compose.foundation.gestures.DefaultScrollableState$scroll$2$1.invoke(Unknown Source:4)
	at androidx.compose.foundation.MutatorMutex$mutateWith$2.invokeSuspend(MutatorMutex.kt:167)
	at androidx.compose.foundation.MutatorMutex$mutateWith$2.invoke(Unknown Source:8)
	at androidx.compose.foundation.MutatorMutex$mutateWith$2.invoke(Unknown Source:4)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndspatched(Undispatched.kt:66)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:286)
	at androidx.compose.foundation.MutatorMutex.mutateWith(MutatorMutex.kt:160)
	at androidx.compose.foundation.gestures.DefaultScrollableState$scroll$2.invokeSuspend(ScrollableState.kt:208)
	at androidx.compose.foundation.gestures.DefaultScrollableState$scroll$2.invoke(Unknown Source:8)
	at androidx.compose.foundation.gestures.DefaultScrollableState$scroll$2.invoke(Unknown Source:4)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndspatched(Undispatched.kt:66)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:286)
	at androidx.compose.foundation.gestures.DefaultScrollableState.scroll(ScrollableState.kt:207)
	at androidx.compose.foundation.lazy.grid.LazyGridState.scroll(LazyGridState.kt:498)
	at androidx.compose.foundation.gestures.ScrollableState.scroll$default(ScrollableState.kt:53)
	at androidx.compose.foundation.lazy.grid.LazyGridState.scrollToItem(LazyGridState.kt:429)
	at org.mozilla.fenix.tabstray.ui.tabpage.TabLayoutKt$TabLayoutScrollHelper$1$1$scrollToItem$2.invoke(TabLayout.kt:221)
	at org.mozilla.fenix.tabstray.ui.tabpage.TabLayoutKt$TabLayoutScrollHelper$1$1$scrollToItem$2.invoke(TabLayout.kt:221)
	at org.mozilla.fenix.tabstray.ui.tabpage.TabLayoutKt$TabLayoutScrollHelper$1$1.invokeSuspend(TabLayout.kt:231)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
	at androidx.compose.ui.test.ApplyingContinuationInterceptor$SendApplyContinuation.resumeWith(ApplyingContinuationInterceptor.kt:52)
	at androidx.compose.ui.test.FrameDeferringContinuationInterceptor$FrameDeferredContinuation.resumeWith(FrameDeferringContinuationInterceptor.jvm.kt:187)
	at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:163)
	at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:152)
	at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:470)
	at kotlinx.coroutines.CancellableContinuationImpl.completeResume(CancellableContinuationImpl.kt:591)
	at kotlinx.coroutines.channels.BufferedChannelKt.tryResume0(BufferedChannel.kt:2957)
	at kotlinx.coroutines.channels.BufferedChannelKt.access$tryResume0(BufferedChannel.kt:1)
	at kotlinx.coroutines.channels.BufferedChannel.tryResumeReceiver(BufferedChannel.kt:666)
	at kotlinx.coroutines.channels.BufferedChannel.updateCellSend(BufferedChannel.kt:478)
	at kotlinx.coroutines.channels.BufferedChannel.access$updateCellSend(BufferedChannel.kt:33)
	at kotlinx.coroutines.channels.BufferedChannel.trySend-JP2dKIU(BufferedChannel.kt:3360)
	at androidx.compose.runtime.SnapshotStateKt__SnapshotFlowKt$snapshotFlow$1.invokeSuspend$lambda$1(SnapshotFlow.kt:130)
	at androidx.compose.runtime.SnapshotStateKt__SnapshotFlowKt$snapshotFlow$1.$r8$lambda$cOJacrzXE2m3qIA2msoWF6a8fHc(Unknown Source:0)
	at androidx.compose.runtime.SnapshotStateKt__SnapshotFlowKt$snapshotFlow$1$$ExternalSyntheticLambda1.invoke(D8$$SyntheticClass:0)
	at androidx.compose.runtime.snapshots.SnapshotKt.advanceGlobalSnapshot(Snapshot.kt:2023)
	at androidx.compose.runtime.snapshots.SnapshotKt.advanceGlobalSnapshot(Snapshot.kt:2037)
	at androidx.compose.runtime.snapshots.SnapshotKt.access$advanceGlobalSnapshot(Snapshot.kt:1)
	at androidx.compose.runtime.snapshots.Snapshot$Companion.sendApplyNotifications(Snapshot.kt:689)
	at androidx.compose.ui.test.ApplyingContinuationInterceptor$SendApplyContinuation.resumeWith(ApplyingContinuationInterceptor.kt:53)
	at androidx.compose.ui.test.FrameDeferringContinuationInterceptor$FrameDeferredContinuation.resumeWith(FrameDeferringContinuationInterceptor.jvm.kt:187)
	at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:163)
	at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:152)
	at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:470)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$kotlinx_coroutines_core(CancellableContinuationImpl.kt:504)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$kotlinx_coroutines_core$default(CancellableContinuationImpl.kt:493)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:359)
	at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke(JobSupport.kt:1557)
	at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:311)
	at kotlinx.coroutines.JobSupport.tryFinalizeSimpleState(JobSupport.kt:288)
	at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:887)
	at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:859)
	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:99)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:47)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)

Hi Gabriel/Julie, can you take a look?

Flags: needinfo?(jdelorenzo)
Flags: needinfo?(iorgamgabriel)
Flags: needinfo?(jdelorenzo)

Bug 2027195 was backed out

Status: NEW → RESOLVED
Closed: 7 months ago
Flags: needinfo?(iorgamgabriel)
Resolution: --- → FIXED
Target Milestone: --- → 151 Branch
You need to log in before you can comment on or make changes to this bug.