Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 44c49090d5f4727e1dc6f883b4345dc0ac487254
Author: Adam Powell <adamp@google.com>
Date: Fri Aug 28 09:02:47 2020
Set MonotonicFrameClock for composition scopes
Install the Recomposer's broadcast frame clock as the CoroutineContext's
MonotonicFrameClock for CoroutineScopes created from composition. This
includes both the launchInComposition and rememberCoroutineScope APIs.
This fixes a bug where users of the withFrameNanos API family would see
the wrong MonotonicFrameClock, leading to animation jank as the ordering
of Choreographer callbacks for the recomposer and the animation with
regard to one another was inconsistent. Installing the Recomposer's clock
into the context allows the Recomposer to control this timing.
Fixes: 166778123
Test: SuspendingEffectsTests.kt
Relnote: "CompositionCoroutineScope no longer implements
MonotonicFrameClock. Callers of withFrameNanos should import the top-level
function explicitly."
Change-Id: Icb642e00a670c235f26d11e6549b4222b2b4c2fb
M compose/runtime/runtime/api/current.txt
M compose/runtime/runtime/api/public_plus_experimental_current.txt
M compose/runtime/runtime/api/restricted_current.txt
M compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/SuspendingEffectsTests.kt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SuspendingEffects.kt
M compose/test-utils/src/androidMain/kotlin/androidx/compose/testutils/AndroidComposeTestCaseRunner.kt
https://android-review.googlesource.com/1413685
Branch: androidx-master-dev
commit 44c49090d5f4727e1dc6f883b4345dc0ac487254
Author: Adam Powell <adamp@google.com>
Date: Fri Aug 28 09:02:47 2020
Set MonotonicFrameClock for composition scopes
Install the Recomposer's broadcast frame clock as the CoroutineContext's
MonotonicFrameClock for CoroutineScopes created from composition. This
includes both the launchInComposition and rememberCoroutineScope APIs.
This fixes a bug where users of the withFrameNanos API family would see
the wrong MonotonicFrameClock, leading to animation jank as the ordering
of Choreographer callbacks for the recomposer and the animation with
regard to one another was inconsistent. Installing the Recomposer's clock
into the context allows the Recomposer to control this timing.
Fixes: 166778123
Test: SuspendingEffectsTests.kt
Relnote: "CompositionCoroutineScope no longer implements
MonotonicFrameClock. Callers of withFrameNanos should import the top-level
function explicitly."
Change-Id: Icb642e00a670c235f26d11e6549b4222b2b4c2fb
M compose/runtime/runtime/api/current.txt
M compose/runtime/runtime/api/public_plus_experimental_current.txt
M compose/runtime/runtime/api/restricted_current.txt
M compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/SuspendingEffectsTests.kt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SuspendingEffects.kt
M compose/test-utils/src/androidMain/kotlin/androidx/compose/testutils/AndroidComposeTestCaseRunner.kt
Description
Coroutine scopes derived from a composition using the
rememberCoroutineScope()
andlaunchInComposition
APIs should have theRecomposer
'sMonotonicFrameClock
in theircoroutineContext
s. The absence of this causes jank in animations performed using thewithFrameNanos
API family as ordering of frame operations with regard to the recomposer loop are not guaranteed. This bug was masked by theCompositionCoroutineScope
receiver used bylaunchInComposition
implementing the frame clock interface and providing the correct one through that side channel.Install the correct frame clock into the
coroutineContext
and removeCompositionCoroutineScope
's interface implementation ofMonotonicFrameClock
.