Bug 211839
Summary: | [Web Animations] Use CA animations when playbackRate != 1 and direction != normal | ||
---|---|---|---|
Product: | WebKit | Reporter: | Antoine Quint <graouts> |
Component: | Animations | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | dino, graouts, mattgperry, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=204717 |
Antoine Quint
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/63182225>
Antoine Quint
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
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
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
(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
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
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
Agreed, bug 229399 is something I will look into soon.