summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/compose/core/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt22
1 files changed, 5 insertions, 17 deletions
diff --git a/packages/SystemUI/compose/core/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt b/packages/SystemUI/compose/core/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
index 350b9c2550c8..b3a7a8e9f874 100644
--- a/packages/SystemUI/compose/core/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
+++ b/packages/SystemUI/compose/core/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
@@ -158,26 +158,14 @@ internal class SceneTransitionLayoutImpl(
BackHandler { onChangeScene(backScene) }
}
- Box(
- Modifier.drawWithContent {
- drawContent()
-
- // At this point, all scenes in scenesToCompose are fully laid out so they
- // are marked as ready. This is necessary because the animation code needs
- // to know the position and size of the elements in each scenes they are in,
- // so [readyScenes] will be used to decide whether the transition is ready
- // (see isTransitionReady() below).
- //
- // We can't do that in a DisposableEffect or SideEffect because those are
- // run between composition and layout. LaunchedEffect could work and might
- // be better, but it looks like launched effects run a frame later than this
- // code so doing this here seems better for performance.
- scenesToCompose.fastForEach { readyScenes[it.key] = true }
- }
- ) {
+ Box {
scenesToCompose.fastForEach { scene ->
val key = scene.key
key(key) {
+ // Mark this scene as ready once it has been composed, laid out and
+ // drawn the first time. We have to do this in a LaunchedEffect here
+ // because DisposableEffect runs between composition and layout.
+ LaunchedEffect(key) { readyScenes[key] = true }
DisposableEffect(key) { onDispose { readyScenes.remove(key) } }
scene.Content(