[Web Animations] Use CA animations when playbackRate != 1 and direction != normal
https://bugs.webkit.org/show_bug.cgi?id=211839
Summary [Web Animations] Use CA animations when playbackRate != 1 and direction != no...
Antoine Quint
Reported 2020-05-13 06:34:20 PDT
When fixing bug 204717 we made it so that we wouldn't attempt to run a CA animation if the animation's playback rate is different than 1. This bug is about trying to lift this restriction.
Attachments
Radar WebKit Bug Importer
Comment 1 2020-05-13 06:34:36 PDT
Antoine Quint
Comment 2 2020-05-20 12:47:00 PDT
Looks like we can make this work with this approach: 1. create a CAAnimation 1. set `animation.duration` to `webAnimation.duration` 2. set `animation.beginTime` to `-webAnimation.currentTime` 2. create a CAAnimationGroup 1. set `group.speed` to `webAnimation.playbackRate` 2. set `group.duration` to `webAnimation.effect.duration - webAnimation.currentTime` 3. set `group.animations` to `[animation]`
Antoine Quint
Comment 3 2020-05-25 05:04:25 PDT
Actually, I think the solution is to set the CAAnimation timeOffset to match the Web Animation's currentTime and set speed to match playbackRate, but set the computed duration on a parent CAANimationGroup to clip.
Matt Perry
Comment 4 2021-08-26 06:40:21 PDT
In creating a library built upon WAAPI the only bugs I've encountered are in Webkit, and the majority of those have involved accelerated animations. These aren't bugs I can reasonably ship to users, and setting playbackRate to 1.000001 to force animations onto the main thread in Webkit has fixed them all. If this ticket gets resolved can you also offer a way to flag to Webkit that an animation shouldn't run on the main thread? Because looking through many of the tickets here, and indeed the linked bug in this one, a quick fix has often been to add conditions when an animation shouldn't run on Core Animation. It would be great if you could extend to developers this same opportunity, as I'm concerned that my hacky solution will re-expose users to timing bugs if they're not fixed before this ticket is resolved.
Matt Perry
Comment 5 2021-08-26 06:42:41 PDT
(In reply to Matt Perry from comment #4) > If this ticket gets resolved can you also offer a way to flag to Webkit that > an animation shouldn't run on the main thread? Apologises, that should read "should run on the main thread". Specifically something like element.animate(keyframes, { _webkitRunOnMainThread: true }) would be appreciated.
Antoine Quint
Comment 6 2021-09-08 07:26:31 PDT
Matt, while I understand where you're coming from, I don't think offering a way to explicitly disable accelerated animations is the right approach. Rather, we need to fix bugs related to accelerated animations, so thanks for filing the bugs you have filed for now and to keep filing them as you find them.
Matt Perry
Comment 7 2021-09-08 08:37:06 PDT
I agree it’s not an ideal approach. In lieu of that would it be possible to consider the main-thread/accelerated synchronisation bugs in https://bugs.webkit.org/show_bug.cgi?id=229399 as a higher priority than this ticket? As it’s the only remaining blocker as of iOS 15
Antoine Quint
Comment 8 2021-09-09 04:05:47 PDT
Agreed, bug 229399 is something I will look into soon.
Note You need to log in before you can comment on or make changes to this bug.