Changeset 234017 in webkit


Ignore:
Timestamp:
Jul 19, 2018 5:06:10 PM (6 years ago)
Author:
graouts@webkit.org
Message:

Flaky crash in AnimationTimeline::cancelOrRemoveDeclarativeAnimation
https://bugs.webkit.org/show_bug.cgi?id=187530
<rdar://problem/42095186>

Reviewed by Dean Jackson.

LayoutTests/imported/mozilla:

Mark a WPT progression now that we correctly ignore animation names that have no matching @keyframes rule.

  • css-animations/test_element-get-animations-expected.txt:

Source/WebCore:

We would crash in cancelOrRemoveDeclarativeAnimation() because updateCSSAnimationsForElement() would pass
nullptr values due to the return value of cssAnimationsByName.take(nameOfAnimationToRemove). This is because
we would create animations for animation names that may be empty or not match an existing @keyframes rule.
Not only was that wasteful, but it was also non-compliant, and as a result of fixing this we're actually
seeing a progression in the CSS Animations WPT tests.

  • animation/AnimationTimeline.cpp:

(WebCore::shouldConsiderAnimation): New function that performs all required steps to see if a provided animation
is valid and has a name that is not "none", not the empty string and matches the name of a @keyframes rule.
(WebCore::AnimationTimeline::updateCSSAnimationsForElement):

  • animation/KeyframeEffectReadOnly.cpp:

(WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): We no longer need to check whether we have
an empty animation name since we're no longer creating CSSAnimation objects in that circumstance.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::isAnimationNameValid): Add a new method that checks whether the provided animation name
a known @keyframes rule.

  • css/StyleResolver.h:

LayoutTests:

Adjust an existing test which assumes an animation might be running when it's not really, so we test the animation is
not running using an alternate method.

  • animations/keyframes-dynamic-expected.txt:
  • animations/keyframes-dynamic.html:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r234015 r234017  
     12018-07-19  Antoine Quint  <graouts@apple.com>
     2
     3        Flaky crash in AnimationTimeline::cancelOrRemoveDeclarativeAnimation
     4        https://bugs.webkit.org/show_bug.cgi?id=187530
     5        <rdar://problem/42095186>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Adjust an existing test which assumes an animation might be running when it's not really, so we test the animation is
     10        not running using an alternate method.
     11
     12        * animations/keyframes-dynamic-expected.txt:
     13        * animations/keyframes-dynamic.html:
     14
    1152018-07-19  Ryan Haddad  <ryanhaddad@apple.com>
    216
  • trunk/LayoutTests/animations/keyframes-dynamic-expected.txt

    r231766 r234017  
    44PASS - "left" property for "box2" element at 0.3s saw something close to: 100
    55PASS - "left" property for "box2" element at 0.7s saw something close to: 200
    6 PASS - "left" property for "box3" element at 0.3s saw something close to: 0
    7 PASS - "left" property for "box3" element at 0.7s saw something close to: 0
    86
  • trunk/LayoutTests/animations/keyframes-dynamic.html

    r231977 r234017  
    2828      ["anim2", 0.3, "box2", "left", 100, 1],
    2929      ["anim2", 0.7, "box2", "left", 200, 1],
    30       ["anim3", 0.3, "box3", "left", 0, 0],
    31       ["anim3", 0.7, "box3", "left", 0, 0],
    3230    ];
    3331
     
    6563        style.sheet.removeRule(box3Index);
    6664
    67         runAnimationTest(expectedValues);
     65        runAnimationTest(expectedValues, () => {
     66            setTimeout(() => {
     67                document.getElementById("result").appendChild(document.createTextNode(`${!box3.getAnimations().length ? "PASS" : "FAIL"} - Animation is not running on box3.`));
     68            })
     69        });
    6870    }
    6971   
  • trunk/LayoutTests/imported/mozilla/ChangeLog

    r233459 r234017  
     12018-07-19  Antoine Quint  <graouts@apple.com>
     2
     3        Flaky crash in AnimationTimeline::cancelOrRemoveDeclarativeAnimation
     4        https://bugs.webkit.org/show_bug.cgi?id=187530
     5        <rdar://problem/42095186>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Mark a WPT progression now that we correctly ignore animation names that have no matching @keyframes rule.
     10
     11        * css-animations/test_element-get-animations-expected.txt:
     12
    1132018-07-03  Antoine Quint  <graouts@apple.com>
    214
  • trunk/LayoutTests/imported/mozilla/css-animations/test_element-get-animations-expected.txt

    r233010 r234017  
    88PASS getAnimations for CSS Animations that have finished but are forwards filling
    99PASS getAnimations for CSS Animations with animation-name: none
    10 FAIL getAnimations for CSS Animations with animation-name: missing assert_equals: getAnimations returns an empty sequence for an element with animation-name: missing expected 0 but got 1
    11 FAIL getAnimations for CSS Animations where the @keyframes rule is added later assert_equals: getAnimations initally only returns Animations for CSS Animations whose animation-name is found expected 1 but got 2
     10PASS getAnimations for CSS Animations with animation-name: missing
     11FAIL getAnimations for CSS Animations where the @keyframes rule is added later assert_equals: getAnimations includes Animation when @keyframes rule is added later expected 2 but got 1
    1212PASS getAnimations for CSS Animations with duplicated animation-name
    1313PASS getAnimations for CSS Animations with empty keyframes rule
  • trunk/Source/WebCore/ChangeLog

    r234013 r234017  
     12018-07-19  Antoine Quint  <graouts@apple.com>
     2
     3        Flaky crash in AnimationTimeline::cancelOrRemoveDeclarativeAnimation
     4        https://bugs.webkit.org/show_bug.cgi?id=187530
     5        <rdar://problem/42095186>
     6
     7        Reviewed by Dean Jackson.
     8
     9        We would crash in cancelOrRemoveDeclarativeAnimation() because updateCSSAnimationsForElement() would pass
     10        nullptr values due to the return value of cssAnimationsByName.take(nameOfAnimationToRemove). This is because
     11        we would create animations for animation names that may be empty or not match an existing @keyframes rule.
     12        Not only was that wasteful, but it was also non-compliant, and as a result of fixing this we're actually
     13        seeing a progression in the CSS Animations WPT tests.
     14
     15        * animation/AnimationTimeline.cpp:
     16        (WebCore::shouldConsiderAnimation): New function that performs all required steps to see if a provided animation
     17        is valid and has a name that is not "none", not the empty string and matches the name of a @keyframes rule.
     18        (WebCore::AnimationTimeline::updateCSSAnimationsForElement):
     19        * animation/KeyframeEffectReadOnly.cpp:
     20        (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): We no longer need to check whether we have
     21        an empty animation name since we're no longer creating CSSAnimation objects in that circumstance.
     22        * css/StyleResolver.cpp:
     23        (WebCore::StyleResolver::isAnimationNameValid): Add a new method that checks whether the provided animation name
     24        a known @keyframes rule.
     25        * css/StyleResolver.h:
     26
    1272018-07-19  Chris Dumez  <cdumez@apple.com>
    228
  • trunk/Source/WebCore/animation/AnimationTimeline.cpp

    r233585 r234017  
    4040#include "RenderView.h"
    4141#include "StylePropertyShorthand.h"
     42#include "StyleResolver.h"
    4243#include "WebAnimationUtilities.h"
    4344#include <wtf/text/TextStream.h>
     
    196197}
    197198
     199static bool shouldConsiderAnimation(Element& element, const Animation& animation)
     200{
     201    if (!animation.isValidAnimation())
     202        return false;
     203
     204    static NeverDestroyed<const String> animationNameNone(MAKE_STATIC_STRING_IMPL("none"));
     205
     206    auto& name = animation.name();
     207    if (name == animationNameNone || name.isEmpty())
     208        return false;
     209
     210    if (auto* styleScope = Style::Scope::forOrdinal(element, animation.nameStyleScopeOrdinal()))
     211        return styleScope->resolver().isAnimationNameValid(name);
     212
     213    return false;
     214}
     215
    198216void AnimationTimeline::updateCSSAnimationsForElement(Element& element, const RenderStyle* currentStyle, const RenderStyle& afterChangeStyle)
    199217{
     
    209227    if (currentStyle && currentStyle->hasAnimations() && afterChangeStyle.hasAnimations() && *(currentStyle->animations()) == *(afterChangeStyle.animations()))
    210228        return;
    211 
    212     static NeverDestroyed<const String> animationNameNone(MAKE_STATIC_STRING_IMPL("none"));
    213229
    214230    // First, compile the list of animation names that were applied to this element up to this point.
     
    218234        for (size_t i = 0; i < previousAnimations->size(); ++i) {
    219235            auto& previousAnimation = previousAnimations->animation(i);
    220             if (previousAnimation.isValidAnimation() && previousAnimation.name() != animationNameNone)
     236            if (shouldConsiderAnimation(element, previousAnimation))
    221237                namesOfPreviousAnimations.add(previousAnimation.name());
    222238        }
     
    237253                // animation object for this animation name.
    238254                cssAnimationsByName.get(name)->setBackingAnimation(currentAnimation);
    239             } else if (currentAnimation.isValidAnimation() && name != animationNameNone) {
     255            } else if (shouldConsiderAnimation(element, currentAnimation)) {
    240256                // Otherwise we are dealing with a new animation name and must create a CSSAnimation for it.
    241257                cssAnimationsByName.set(name, CSSAnimation::create(element, currentAnimation, currentStyle, afterChangeStyle));
  • trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp

    r233903 r234017  
    872872    auto cssAnimation = downcast<CSSAnimation>(animation());
    873873    auto& backingAnimation = cssAnimation->backingAnimation();
    874     if (backingAnimation.name().isEmpty())
    875         return;
    876874
    877875    KeyframeList keyframeList(backingAnimation.name());
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r233877 r234017  
    461461}
    462462
     463bool StyleResolver::isAnimationNameValid(const String& name)
     464{
     465    return m_keyframesRuleMap.find(AtomicString(name).impl()) != m_keyframesRuleMap.end();
     466}
     467
    463468void StyleResolver::keyframeStylesForAnimation(const Element& element, const RenderStyle* elementStyle, KeyframeList& list)
    464469{
  • trunk/Source/WebCore/css/StyleResolver.h

    r233838 r234017  
    162162    void setNewStateWithElement(const Element&);
    163163    std::unique_ptr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleRuleKeyframe*, KeyframeValue&);
     164    bool isAnimationNameValid(const String&);
    164165
    165166public:
Note: See TracChangeset for help on using the changeset viewer.