⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244031 in webkit


Ignore:
Timestamp:
Apr 8, 2019, 11:49:04 AM (7 years ago)
Author:
graouts@webkit.org
Message:

[Web Animations] JS wrapper may be deleted while animation is yet to dispatch its finish event
https://bugs.webkit.org/show_bug.cgi?id=196118
<rdar://problem/46614137>

Reviewed by Chris Dumez.

Source/WebCore:

Test: webanimations/js-wrapper-kept-alive.html

We need to teach WebAnimation to keep its JS wrapper alive if it's relevant or could become relevant again by virtue of having a timeline.
We also need to ensure that the new implementation of hasPendingActivity() does not interfere with the ability of pages to enter the page
cache when running animations.

  • animation/WebAnimation.cpp:

(WebCore::WebAnimation::canSuspendForDocumentSuspension const):
(WebCore::WebAnimation::stop):
(WebCore::WebAnimation::hasPendingActivity const):

  • animation/WebAnimation.h:

LayoutTests:

Add a test that starts a short animation, sets a custom property on it, registers a "finish" event listener on it and deletes
the sole reference to it in the JS world before triggering garbage collection. Prior to this fix, this test would time out
because the JS wrapper would be garbage-collected prior to the animation completing and thus the event listener would not
be called. To complete successfully, this test checks that it receives the event and its target is the same animation object
that was originally created by checking the custom property is still set.

We also make sure that a test, which was found to have regressed with a previous version of this patch, uses the animation
engine that it is expected to be testing.

  • legacy-animation-engine/animations/resume-after-page-cache.html:
  • webanimations/js-wrapper-kept-alive-expected.txt: Added.
  • webanimations/js-wrapper-kept-alive.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r244029 r244031  
     12019-04-08  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] JS wrapper may be deleted while animation is yet to dispatch its finish event
     4        https://bugs.webkit.org/show_bug.cgi?id=196118
     5        <rdar://problem/46614137>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Add a test that starts a short animation, sets a custom property on it, registers a "finish" event listener on it and deletes
     10        the sole reference to it in the JS world before triggering garbage collection. Prior to this fix, this test would time out
     11        because the JS wrapper would be garbage-collected prior to the animation completing and thus the event listener would not
     12        be called. To complete successfully, this test checks that it receives the event and its target is the same animation object
     13        that was originally created by checking the custom property is still set.
     14
     15        We also make sure that a test, which was found to have regressed with a previous version of this patch, uses the animation
     16        engine that it is expected to be testing.
     17
     18        * legacy-animation-engine/animations/resume-after-page-cache.html:
     19        * webanimations/js-wrapper-kept-alive-expected.txt: Added.
     20        * webanimations/js-wrapper-kept-alive.html: Added.
     21
    1222019-04-08  Eric Liang  <ericliang@apple.com>
    223
  • trunk/LayoutTests/legacy-animation-engine/animations/resume-after-page-cache.html

    r243917 r244031  
     1<!-- webkit-test-runner [ experimental:WebAnimationsCSSIntegrationEnabled=false ] -->
    12<style>
    23@-webkit-keyframes bounce {
  • trunk/Source/WebCore/ChangeLog

    r244029 r244031  
     12019-04-08  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] JS wrapper may be deleted while animation is yet to dispatch its finish event
     4        https://bugs.webkit.org/show_bug.cgi?id=196118
     5        <rdar://problem/46614137>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Test: webanimations/js-wrapper-kept-alive.html
     10
     11        We need to teach WebAnimation to keep its JS wrapper alive if it's relevant or could become relevant again by virtue of having a timeline.
     12        We also need to ensure that the new implementation of hasPendingActivity() does not interfere with the ability of pages to enter the page
     13        cache when running animations.
     14
     15        * animation/WebAnimation.cpp:
     16        (WebCore::WebAnimation::canSuspendForDocumentSuspension const):
     17        (WebCore::WebAnimation::stop):
     18        (WebCore::WebAnimation::hasPendingActivity const):
     19        * animation/WebAnimation.h:
     20
    1212019-04-08  Eric Liang  <ericliang@apple.com>
    222
  • trunk/Source/WebCore/animation/WebAnimation.cpp

    r243917 r244031  
    11581158bool WebAnimation::canSuspendForDocumentSuspension() const
    11591159{
    1160     return !hasPendingActivity();
     1160    // Use the base class's implementation of hasPendingActivity() since we wouldn't want the custom implementation
     1161    // in this class designed to keep JS wrappers alive to interfere with the ability for a page using animations
     1162    // to enter the page cache.
     1163    return !ActiveDOMObject::hasPendingActivity();
    11611164}
    11621165
    11631166void WebAnimation::stop()
    11641167{
     1168    ActiveDOMObject::stop();
    11651169    m_isStopped = true;
    11661170    removeAllEventListeners();
     1171}
     1172
     1173bool WebAnimation::hasPendingActivity() const
     1174{
     1175    // Keep the JS wrapper alive if the animation is considered relevant or could become relevant again by virtue of having a timeline.
     1176    return m_timeline || m_isRelevant || ActiveDOMObject::hasPendingActivity();
    11671177}
    11681178
  • trunk/Source/WebCore/animation/WebAnimation.h

    r243917 r244031  
    119119    virtual void remove();
    120120
     121    bool hasPendingActivity() const final;
     122
    121123    using RefCounted::ref;
    122124    using RefCounted::deref;
Note: See TracChangeset for help on using the changeset viewer.