Bug 202360 - Animations stop if new tab opened (and closed)
Summary: Animations stop if new tab opened (and closed)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: Safari 12
Hardware: All macOS 10.14
: P2 Critical
Assignee: Antoine Quint
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-09-30 02:39 PDT by Laszlo Varga
Modified: 2019-12-19 03:32 PST (History)
8 users (show)

See Also:


Attachments
Test (918 bytes, text/html)
2019-12-18 03:21 PST, Antoine Quint
no flags Details
Patch (8.66 KB, patch)
2019-12-18 10:50 PST, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch for landing (10.42 KB, patch)
2019-12-18 15:45 PST, Antoine Quint
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Laszlo Varga 2019-09-30 02:39:34 PDT
I have got an error only in Safari browser.

Please visit this link see it

https://codepen.io/Lacika1981/pen/jONogML

If you open a new tab or visit an already open tab then the current animation finishes but the next one(s) plays only the very last frames of each animation.

The animations created this way are rejected by Google QA. It is critical as banners' animations stops working.
Comment 1 Laszlo Varga 2019-09-30 02:50:14 PDT
Here is piece of code taken from HTML banner.

@keyframes gwd-gen-1gaigwdanimation_gwd-keyframes {
      0% {
        opacity: 1;
        left: 46px;
        animation-timing-function: linear;
      }
      84.8485% {
        opacity: 1;
        left: 46px;
        animation-timing-function: linear;
      }
      100% {
        opacity: 0;
        left: 46px;
        animation-timing-function: linear;
      }
    }
    #page1.gwd-play-animation .gwd-gen-1gaigwdanimation {
      animation: 3.3s linear 0s 1 normal forwards running gwd-gen-1gaigwdanimation_gwd-keyframes;
    }
    @keyframes gwd-gen-1thxgwdanimation_gwd-keyframes {
      0% {
        left: 46px;
        opacity: 0;
        animation-timing-function: linear;
      }
      19.2308% {
        left: 46px;
        opacity: 1;
        animation-timing-function: linear;
      }
      80.7692% {
        left: 46px;
        opacity: 1;
        animation-timing-function: linear;
      }
      100% {
        left: 46px;
        opacity: 0;
        animation-timing-function: linear;
      }
    }
    #page1.gwd-play-animation .gwd-gen-1thxgwdanimation {
      animation: 2.6s linear 3.3s 1 normal forwards running gwd-gen-1thxgwdanimation_gwd-keyframes;
    }

This code has been generated by Google Web Designer app.

As I said in my first comment the animation breaks only in Safari browser and maybe caused by the delay.
Comment 2 Laszlo Varga 2019-09-30 03:02:07 PDT
I have done test and the problem definitely caused by the delay property.

If I use animations without delay but changing the steps then the animations play fine. I.e. I want an animation starts from 3s and change opacity from 0 to 1 then instead of using 3s delay I make changes to the steps.

Eaxapmle:

Each animation lasts 6s but the second one will change opacity to 1 at 3s

@keyframes anim1 {
      0% {
        opacity: 1;
        left: 46px;
        animation-timing-function: linear;
      }
      50% {
        opacity: 1;
        left: 46px;
        animation-timing-function: linear;
      }
      51% {
        opacity: 0;
        left: 46px;
        animation-timing-function: linear;
      }
      100% {
        opacity: 0;
        left: 46px;
        animation-timing-function: linear;
      }
}

@keyframes anim1 {
      0% {
        opacity: 0;
        left: 46px;
        animation-timing-function: linear;
      }
      50% {
        opacity: 0;
        left: 46px;
        animation-timing-function: linear;
      }
      51% {
        opacity: 1;
        left: 46px;
        animation-timing-function: linear;
      }
      100% {
        opacity: 1;
        left: 46px;
        animation-timing-function: linear;
      }
}

This way the animations work fine. Using delay they break
Comment 3 Alexey Proskuryakov 2019-10-02 13:54:43 PDT
Ugh. Thank you for the test case!
Comment 4 Radar WebKit Bug Importer 2019-10-02 13:55:49 PDT
<rdar://problem/55923261>
Comment 5 Antoine Quint 2019-10-08 07:46:34 PDT
I can reproduce the issue with the default settings, but in STP 93, if I ensure both "Web Animations" and "CSS Animations via Web Animations" are checked under Develop > Experimental Features, the animation behaves as expected.
Comment 6 Antoine Quint 2019-10-08 07:47:04 PDT
Laszlo, would you mind verifying that is indeed the case?
Comment 7 Antoine Quint 2019-12-18 03:08:24 PST
Actually, with ToT, the initial color animation works as expected, but the translation animation pauses immediately after starting and then just snaps to intermediate values. Looking into this now.
Comment 8 Antoine Quint 2019-12-18 03:21:39 PST
Created attachment 385953 [details]
Test
Comment 9 Antoine Quint 2019-12-18 03:34:00 PST
This is an issue with accelerated animations, using margin-left instead of transform for the nudge and nudge-2 animations fixes the issue.
Comment 10 Antoine Quint 2019-12-18 06:22:32 PST
As it turns out, the animation is not accelerated because we mix software-based animations (background-color) and accelerated animations (transform). However we do create a layer for the element while the transform animations should be running but fail to commit the accelerated animations, which disables the software animation code.

In the old engine we would run accelerated animations when mixing accelerated and non-accelerated properties. We should bring this back.
Comment 11 Antoine Quint 2019-12-18 10:50:34 PST
Created attachment 385984 [details]
Patch
Comment 12 Dean Jackson 2019-12-18 10:52:14 PST
Comment on attachment 385984 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=385984&action=review

> Source/WebCore/animation/KeyframeEffect.cpp:1396
> +    // In the case where we have a composited renderer, we'll be applyng all pending accelerated actions.

Typo applyng

> Source/WebCore/animation/KeyframeEffect.cpp:1406
> +        // we should reset the flag to run acceleratd.

Typo acceleratd
Comment 13 Antoine Quint 2019-12-18 15:45:08 PST
Created attachment 386024 [details]
Patch for landing
Comment 14 WebKit Commit Bot 2019-12-18 16:30:53 PST
Comment on attachment 386024 [details]
Patch for landing

Clearing flags on attachment: 386024

Committed r253728: <https://trac.webkit.org/changeset/253728>
Comment 15 WebKit Commit Bot 2019-12-18 16:30:55 PST
All reviewed patches have been landed.  Closing bug.
Comment 16 Antoine Quint 2019-12-19 03:32:54 PST
Reset the platform-specific expectation for imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements.html in r253746. I did that originally because that's what EWS was warning me about but now the bots are definitely not happy with that.