-
Notifications
You must be signed in to change notification settings - Fork 232
Proposed fix to correct Compose UI animations #1645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
b3babf7
to
3079a30
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good. Having to render twice with a 0 start time is a little quirky but the comment explains it well
d4adf47
to
d9ebe08
Compare
renderSession.render(false) | ||
} | ||
} | ||
|
||
for (frame in 0 until frameCount) { | ||
val nowNanos = (startNanos + (frame * 1_000_000_000.0 / fps)).toLong() | ||
|
||
// If we have pendingTasks run recomposer to ensure we get the correct frame. | ||
var hasPendingWork = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @geoff-powell, spotted a subtle bug here. hasPendingWork
is a computed property backed by synchronized state in Recomposer, so storing its value in a local var like this might introduce an issue if the underlying state changes between reads (which is likely during animation rendering).
Would it make sense to unwrap recomposer
once, then query recomposerInstance.hasPendingWork
at the moment it's needed, instead of snapshotting into a local var?
That way the logic stays aligned with Recomposer's live state, like:
if (frame == 0 && recomposerInstance.hasPendingWork) {
withTime(nowNanos) {
renderForResult()
}
if (recomposerInstance.hasPendingWork) {
logger.warning("...")
}
}
d9ebe08
to
8724f46
Compare
So animations with
offsetMillis
didn't work properly in paparazzi. This was due to the Transition apis tracking thestartTimeNanos
when a transition starts. Since this is set ahead of the transition, the delta to render the frame was always 0. Forgif()
methods that usedstart = 0
they render correctly because the starting frame is at0
nanos.The best way I could combat this was for cases in Compose where the caller was manually setting the
startNanos
forPaparazzi.takeSnapshots()
I call multiple render calls with time 0 to ensure Transition apis havestartTimeNanos = 0
Fixes #627 #678