-
Notifications
You must be signed in to change notification settings - Fork 715
[web-animations-1] Fixed play animation procedure for scroll animations (#2075) #5059
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
Conversation
Do you have an example (or test?) for this? It seems odd that we sometimes apply the pending playback rate immediately and sometimes apply it in the ready task. It would be nice to see an example/test for the second point too so I can understand it better. |
Here are the failing tests you requested.
|
Thank you! Thinking about this, I think this is just an artifact of the fact that we are seeking using the start time rather than the hold time -- hence the effect doesn't take place until the animation is ready. But thinking about this further, currently the whole point of the pending task is typically to resolve a suitable start time. That's why setting the start time cancels any pending tasks. Do we now want animations to remain pending if they don't have an active timeline? If so, we need to update the procedure to set the start time (and possibly other places). If not, we could possibly just call that procedure here instead. |
- Enabled pause(), reverse() and updatePlaybackRate() APIs for scroll animations. - Provided temporary fix for play animation procedure to accommodate reverse() and replaying finished animation cases. The fix reflects pending w3c/csswg-drafts#5059. - Ported wpt/web-animations/timing-model/animations tests that exercise the APIs. - Implemented scroll animation specific tests. Bug: 916117 Change-Id: I689e7a6d1f220ee12e7f7a6f90e54340eaa33aee
I was also thinking that perhaps initializing start time in play() should work the same as setting the start time regardless of timeline activeness. However I convinced myself otherwise to keep scroll and time linked animations behave similarly in terms of timing of resolving Ready promise and the value of pending flag. In addition, calling play() on pause pending animation has the same effect - hold time unresolved, start time is resolved and Ready promise is resolved asynchronously.
Are you referring to finite inactive timelines or in general? |
There's a parallel though because both My concern is that it feels odd that we are sometimes running the procedure to apply the pending playback rate synchronously and sometimes asynchronously. Don't you think that feels a bit odd? A bit unpredictable? If we could do the whole thing synchronously by invoking the set the start time procedure, that would at least be more consistent. But I'm actually starting to wonder if the issue needs to be fixed in the first place. Could we just say that the current time is out of date until the animation is ready? (As opposed to the start time being out of date.) For the second test, clearing the hold time probably makes sense (I need to double-check). Sorry, it takes me a long time each time to try and remember how this all fits together. |
Yes, I agree that it's inconsistent and odd. But perhaps it can be explained that while scroll animation is pending, calculating current time requires up to date playback_rate.
I prototyped this in Chromium and ran all the timing tests. I didn't find any failures with the exception of pending flag being false after play() and timing of ready promise. Note that update an animations finished state invoked from setting the start time (see the last bullet) should be called with did seek flag set to false. Alternatively play task can be called synchronously from play(). This is probably the right way to go since there is no really pending actions that can not be accomplished synchronously. I am just worried that it can complicate user scripts when both scroll and time linked animations are involved.
What does it mean the current time is out of date? Unresolved and no effect? If so it's inconsistent with time linked animations in pending state. Perhaps I am missing something? |
Yes, that's a very valid concern. However, I think by calling the procedure to set the start time the Promise resolution procedure will mean those callbacks get called at the next microtask checkpoint so those code will still act more-or-less the same in both cases. The only difference is that the (And the more I think about it, the more I wonder if the pending playback rate actually needs to be applied asychronously for While we're touching this procedure, I wonder if it would be more neat to drop the performed seek flag and set a local seek time variable. Then, if that value was set, before step 6 we'd either update the hold time or call the set the start time procedure? (And possibly clear the hold time value there too as per this PR?) Thanks for all your work on this. Unfortunately I think at this time it's only you and I who are really familiar with these procedures and they're very complicated. I wish we could make them all simpler somehow! |
I am not the right reviewer here. Perhaps @kevers-google has some opinion on the matter. He implemented most of the pending play/pause implementation in Chromium and knows the procedures in much more depth. |
Looking at the first failure (will address second in followup post): // Schedule animation to start playing. // Update the hold time since we don’t yet have a start time. Pending pauses are // Change pending playback rate to -1 and trigger the steps to play an animation Ensuring that hold time is cleared whenever start time is set should resolve this problem. Since we update the finished state as the last step in the process, we don't need to worry about clearing the hold time if the animation is finished (it'll simply be re-resolved). |
Problem 2 looks like it has a common route cause as setting the start time, but not clearing the hold time leaves the animation in a weird state. Looks like tweaking step 5 in: https://drafts.csswg.org/web-animations-1/#playing-an-animation-section to reset the hold time when setting the start time could resolve both failures. |
- Enabled pause(), reverse() and updatePlaybackRate() APIs for scroll animations. - Provided temporary fix for play animation procedure to accommodate reverse() and replaying finished animation cases. The fix reflects pending w3c/csswg-drafts#5059. - Ported wpt/web-animations/timing-model/animations tests that exercise the APIs. - Implemented scroll animation specific tests. Bug: 916117 Change-Id: I689e7a6d1f220ee12e7f7a6f90e54340eaa33aee
Applying pending playback rate asynchronously makes a difference when reversing or calling updatePlaybackRate() on running animation. In these cases play pending task needs both the current and pending playback rates to recalculate start time to match the current time.
I was thinking more about diverging play procedure for scroll animations to call set start time. I feel like this inconsistency is "more inconsistent" than applying pending playback rate. How about we generalize updating playback rate asynchronously only when it's needed? In this case the condition will be:
|
Ok, please help me try to understand. I believe Kevin is suggesting that simply resetting the hold time when setting the start time is enough to fix both problems? Is that correct? Olga, does that work?
Oh, good point.
I'm not quite sure I follow. Does this mean that you prefer we don't call the "set start time" procedure but just directly apply the pending playback rate? Is there anything in particular that you feel is better about that? (I'm wondering if calling the "set start time" procedure is better since we skip the pending state, and that's better since the UA doesn't actually have any time values to resolve asynchronously?)
That's interesting. What would that help with? In any case, I still want to refactor this to make step 5 simply set a local seek time variable, and then, as a separate step, update either the hold time or start time based on the value of finite timeline. Once we do that, it would be easier to clear the pending playback rate there too if we decide to do that. |
- Enabled pause(), reverse() and updatePlaybackRate() APIs for scroll animations. - Provided temporary fix for play animation procedure to accommodate reverse() and replaying finished animation cases. The fix reflects pending w3c/csswg-drafts#5059. - Ported wpt/web-animations/timing-model/animations tests that exercise the APIs. - Implemented scroll animation specific tests. Bug: 916117 Change-Id: I689e7a6d1f220ee12e7f7a6f90e54340eaa33aee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2194586 Reviewed-by: Kevin Ellis <kevers@chromium.org> Commit-Queue: Olga Gerchikov <gerchiko@microsoft.com> Cr-Commit-Position: refs/heads/master@{#771881}
- Enabled pause(), reverse() and updatePlaybackRate() APIs for scroll animations. - Provided temporary fix for play animation procedure to accommodate reverse() and replaying finished animation cases. The fix reflects pending w3c/csswg-drafts#5059. - Ported wpt/web-animations/timing-model/animations tests that exercise the APIs. - Implemented scroll animation specific tests. Bug: 916117 Change-Id: I689e7a6d1f220ee12e7f7a6f90e54340eaa33aee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2194586 Reviewed-by: Kevin Ellis <kevers@chromium.org> Commit-Queue: Olga Gerchikov <gerchiko@microsoft.com> Cr-Commit-Position: refs/heads/master@{#771881}
- Enabled pause(), reverse() and updatePlaybackRate() APIs for scroll animations. - Provided temporary fix for play animation procedure to accommodate reverse() and replaying finished animation cases. The fix reflects pending w3c/csswg-drafts#5059. - Ported wpt/web-animations/timing-model/animations tests that exercise the APIs. - Implemented scroll animation specific tests. Bug: 916117 Change-Id: I689e7a6d1f220ee12e7f7a6f90e54340eaa33aee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2194586 Reviewed-by: Kevin Ellis <kevers@chromium.org> Commit-Queue: Olga Gerchikov <gerchiko@microsoft.com> Cr-Commit-Position: refs/heads/master@{#771881}
Second commit has the refactoring per your suggestion, both play and pause procedures. It's much cleaner now.
I spoke to Kevin offline and his point was that clearing hold time is required but not sufficient for the reverse() case.
Yes, I prefer we don't call "set start time" from play. I also spoke to Kevin about it and his preference is alike. He is concerned that differences in timing of ready promise resolution might complicate user scrips. In the example below, pause() resolves new promise for scroll animations, versus the one from play() procedure for the time based animations (see Pausing an animation step 7).
This is my attempt to generalize when playback rate doesn't need to be updated asynchronously so animation type is not a factor in the logic. In general, it feels like differences in timing of updating playback rate is a "lesser evil" than having pretty much different play procedure for scroll animations. However I'll trust your judgement since you are the expert and my opinion is more based on intuition rather than real data. |
That latest patch looks really really good. I'd still be curious to hear if you have answers to the questions from my previous comment. It would be good to get @kevers-google's review too. |
Thanks @birtles for reviewing. I thought I answered all the questions. Did I miss anything? |
Sorry, this is really really odd, but I promise I looked for your answer before posting my question and it wasn't there (maybe I had a cached version of this page?). I see it now. Thank you! |
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.
Very nice. Much easier to follow the flow.
…imations, a=testonly Automatic update from web-platform-tests Enabled Web Animation APIs for scroll animations - Enabled pause(), reverse() and updatePlaybackRate() APIs for scroll animations. - Provided temporary fix for play animation procedure to accommodate reverse() and replaying finished animation cases. The fix reflects pending w3c/csswg-drafts#5059. - Ported wpt/web-animations/timing-model/animations tests that exercise the APIs. - Implemented scroll animation specific tests. Bug: 916117 Change-Id: I689e7a6d1f220ee12e7f7a6f90e54340eaa33aee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2194586 Reviewed-by: Kevin Ellis <kevers@chromium.org> Commit-Queue: Olga Gerchikov <gerchiko@microsoft.com> Cr-Commit-Position: refs/heads/master@{#771881} -- wpt-commits: 1afcb0f78cd1f6ec37d64f9bce4220102a6dc0a2 wpt-pr: 23533
…imations, a=testonly Automatic update from web-platform-tests Enabled Web Animation APIs for scroll animations - Enabled pause(), reverse() and updatePlaybackRate() APIs for scroll animations. - Provided temporary fix for play animation procedure to accommodate reverse() and replaying finished animation cases. The fix reflects pending w3c/csswg-drafts#5059. - Ported wpt/web-animations/timing-model/animations tests that exercise the APIs. - Implemented scroll animation specific tests. Bug: 916117 Change-Id: I689e7a6d1f220ee12e7f7a6f90e54340eaa33aee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2194586 Reviewed-by: Kevin Ellis <kevers@chromium.org> Commit-Queue: Olga Gerchikov <gerchiko@microsoft.com> Cr-Commit-Position: refs/heads/master@{#771881} -- wpt-commits: 1afcb0f78cd1f6ec37d64f9bce4220102a6dc0a2 wpt-pr: 23533
These changes were made to bring the implementation into alignment with recent spec changes: w3c/csswg-drafts#5059 Inline spec comments were updated to match as well. Bug: 1081267 Change-Id: Ic4186905377c836b644fed158efe25c369b4cfe0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386339 Reviewed-by: Olga Gerchikov <gerchiko@microsoft.com> Reviewed-by: Kevin Ellis <kevers@chromium.org> Commit-Queue: Jordan Taylor <jortaylo@microsoft.com> Cr-Commit-Position: refs/heads/master@{#803575}
…imations, a=testonly Automatic update from web-platform-tests Enabled Web Animation APIs for scroll animations - Enabled pause(), reverse() and updatePlaybackRate() APIs for scroll animations. - Provided temporary fix for play animation procedure to accommodate reverse() and replaying finished animation cases. The fix reflects pending w3c/csswg-drafts#5059. - Ported wpt/web-animations/timing-model/animations tests that exercise the APIs. - Implemented scroll animation specific tests. Bug: 916117 Change-Id: I689e7a6d1f220ee12e7f7a6f90e54340eaa33aee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2194586 Reviewed-by: Kevin Ellis <kevers@chromium.org> Commit-Queue: Olga Gerchikov <gerchiko@microsoft.com> Cr-Commit-Position: refs/heads/master@{#771881} -- wpt-commits: 1afcb0f78cd1f6ec37d64f9bce4220102a6dc0a2 wpt-pr: 23533
#4842 is missing updates required to handle reverse() API and re-playing finished animations: