Title: [227841] trunk
Revision
227841
Author
[email protected]
Date
2018-01-30 11:46:38 -0800 (Tue, 30 Jan 2018)

Log Message

CrashTracer: com.apple.WebKit.WebContent at WebCore: WebCore::Document::updateStyleIfNeeded
https://bugs.webkit.org/show_bug.cgi?id=182299
<rdar://problem/36853088>

Reviewed by Simon Fraser.

Source/WebCore:

Mostly speculative fix for the case where a scrollTo moves an
animated SVG image into view, causing its animation to restart during
a paint operation. This was causing a release ASSERT, so we now defer
the resumption of the animation into a timer.

Test: svg/animated-svgImage-scroll.html

* rendering/RenderElement.cpp:
(WebCore::RenderElement::repaintForPausedImageAnimationsIfNeeded): Enqueue the
animation if it is an SVGImage.
* svg/graphics/SVGImage.cpp: Add a timer to enqueue animation starts.
(WebCore::SVGImage::SVGImage):
(WebCore::SVGImage::startAnimationTimerFired):
(WebCore::SVGImage::enqueueStartAnimation):
(WebCore::SVGImage::stopAnimation):
* svg/graphics/SVGImage.h:

LayoutTests:

* svg/animated-svgImage-scroll-expected.txt: Added.
* svg/animated-svgImage-scroll.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (227840 => 227841)


--- trunk/LayoutTests/ChangeLog	2018-01-30 19:45:54 UTC (rev 227840)
+++ trunk/LayoutTests/ChangeLog	2018-01-30 19:46:38 UTC (rev 227841)
@@ -1,3 +1,14 @@
+2018-01-30  Dean Jackson  <[email protected]>
+
+        CrashTracer: com.apple.WebKit.WebContent at WebCore: WebCore::Document::updateStyleIfNeeded
+        https://bugs.webkit.org/show_bug.cgi?id=182299
+        <rdar://problem/36853088>
+
+        Reviewed by Simon Fraser.
+
+        * svg/animated-svgImage-scroll-expected.txt: Added.
+        * svg/animated-svgImage-scroll.html: Added.
+
 2018-01-30  Frederic Wang  <[email protected]>
 
         Unreviewed test gardening.

Added: trunk/LayoutTests/svg/animated-svgImage-scroll-expected.txt (0 => 227841)


--- trunk/LayoutTests/svg/animated-svgImage-scroll-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/animated-svgImage-scroll-expected.txt	2018-01-30 19:46:38 UTC (rev 227841)
@@ -0,0 +1,8 @@
+Before text
+
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+
+After text
Property changes on: trunk/LayoutTests/svg/animated-svgImage-scroll-expected.txt
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Revision \ No newline at end of property

Added: svn:mime-type

+text/plain \ No newline at end of property

Added: trunk/LayoutTests/svg/animated-svgImage-scroll.html (0 => 227841)


--- trunk/LayoutTests/svg/animated-svgImage-scroll.html	                        (rev 0)
+++ trunk/LayoutTests/svg/animated-svgImage-scroll.html	2018-01-30 19:46:38 UTC (rev 227841)
@@ -0,0 +1,41 @@
+<style>
+    #container {
+        overflow: scroll;
+        width: 300px;
+        height: 200px;
+    }
+    #expander {
+        background-color: blue;
+        height: 500px;
+    }
+</style>
+<p>Before text</p>
+<div id="container">
+    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+    <img src="" width="200" height="100"></img>
+    <p id="expander"></p>
+</div>
+<p>After text</p>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function run() {
+    let container = document.getElementById("container");
+    container.scrollTo(0, 1000);
+    setTimeout(function () {
+        let expander = document.getElementById("expander");
+        expander.style.height = "1px";
+        if (window.testRunner) {
+            setTimeout(function () {
+                testRunner.notifyDone();
+            }, 0);
+        }
+    }, 0);
+}
+
+window.addEventListener("load", run, false);
+</script>
\ No newline at end of file
Property changes on: trunk/LayoutTests/svg/animated-svgImage-scroll.html
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Revision \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Modified: trunk/Source/WebCore/ChangeLog (227840 => 227841)


--- trunk/Source/WebCore/ChangeLog	2018-01-30 19:45:54 UTC (rev 227840)
+++ trunk/Source/WebCore/ChangeLog	2018-01-30 19:46:38 UTC (rev 227841)
@@ -1,3 +1,28 @@
+2018-01-30  Dean Jackson  <[email protected]>
+
+        CrashTracer: com.apple.WebKit.WebContent at WebCore: WebCore::Document::updateStyleIfNeeded
+        https://bugs.webkit.org/show_bug.cgi?id=182299
+        <rdar://problem/36853088>
+
+        Reviewed by Simon Fraser.
+
+        Mostly speculative fix for the case where a scrollTo moves an
+        animated SVG image into view, causing its animation to restart during
+        a paint operation. This was causing a release ASSERT, so we now defer
+        the resumption of the animation into a timer.
+
+        Test: svg/animated-svgImage-scroll.html
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::repaintForPausedImageAnimationsIfNeeded): Enqueue the
+        animation if it is an SVGImage.
+        * svg/graphics/SVGImage.cpp: Add a timer to enqueue animation starts.
+        (WebCore::SVGImage::SVGImage):
+        (WebCore::SVGImage::startAnimationTimerFired):
+        (WebCore::SVGImage::enqueueStartAnimation):
+        (WebCore::SVGImage::stopAnimation):
+        * svg/graphics/SVGImage.h:
+
 2018-01-30  Chris Dumez  <[email protected]>
 
         Service worker registration soft updates happen too frequently

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (227840 => 227841)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2018-01-30 19:45:54 UTC (rev 227840)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2018-01-30 19:46:38 UTC (rev 227841)
@@ -68,6 +68,7 @@
 #include "RenderTheme.h"
 #include "RenderTreeBuilder.h"
 #include "RenderView.h"
+#include "SVGImage.h"
 #include "SVGRenderSupport.h"
 #include "Settings.h"
 #include "ShadowRoot.h"
@@ -1468,8 +1469,14 @@
 
     repaint();
 
-    if (auto* image = cachedImage.image())
-        image->startAnimation();
+    if (auto* image = cachedImage.image()) {
+        // SVGImages might cause a layout when starting an animation, so
+        // schedule them rather than start immediately.
+        if (is<SVGImage>(image))
+            downcast<SVGImage>(image)->scheduleStartAnimation();
+        else
+            image->startAnimation();
+    }
 
     // For directly-composited animated GIFs it does not suffice to call repaint() to resume animation. We need to mark the image as changed.
     if (is<RenderBoxModelObject>(*this))

Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (227840 => 227841)


--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp	2018-01-30 19:45:54 UTC (rev 227840)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp	2018-01-30 19:46:38 UTC (rev 227841)
@@ -69,6 +69,7 @@
 
 SVGImage::SVGImage(ImageObserver& observer)
     : Image(&observer)
+    , m_startAnimationTimer(*this, &SVGImage::startAnimationTimerFired)
 {
 }
 
@@ -377,6 +378,19 @@
         intrinsicRatio = FloatSize(floatValueForLength(intrinsicWidth, 0), floatValueForLength(intrinsicHeight, 0));
 }
 
+void SVGImage::startAnimationTimerFired()
+{
+    startAnimation();
+}
+
+void SVGImage::scheduleStartAnimation()
+{
+    auto rootElement = this->rootElement();
+    if (!rootElement || !rootElement->animationsPaused())
+        return;
+    m_startAnimationTimer.startOneShot(0_s);
+}
+
 void SVGImage::startAnimation()
 {
     auto rootElement = this->rootElement();
@@ -388,6 +402,7 @@
 
 void SVGImage::stopAnimation()
 {
+    m_startAnimationTimer.stop();
     auto rootElement = this->rootElement();
     if (!rootElement)
         return;

Modified: trunk/Source/WebCore/svg/graphics/SVGImage.h (227840 => 227841)


--- trunk/Source/WebCore/svg/graphics/SVGImage.h	2018-01-30 19:45:54 UTC (rev 227840)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.h	2018-01-30 19:46:38 UTC (rev 227841)
@@ -60,6 +60,8 @@
     void resetAnimation() final;
     bool isAnimating() const final;
 
+    void scheduleStartAnimation();
+
 #if USE(CAIRO)
     NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final;
 #endif
@@ -89,6 +91,8 @@
     // FIXME: Implement this to be less conservative.
     bool currentFrameKnownToBeOpaque() const final { return false; }
 
+    void startAnimationTimerFired();
+
     explicit SVGImage(ImageObserver&);
     ImageDrawResult draw(GraphicsContext&, const FloatRect& fromRect, const FloatRect& toRect, CompositeOperator, BlendMode, DecodingMode, ImageOrientationDescription) final;
     ImageDrawResult drawForContainer(GraphicsContext&, const FloatSize containerSize, float containerZoom, const URL& initialFragmentURL, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator, BlendMode);
@@ -100,6 +104,8 @@
     std::unique_ptr<SVGImageChromeClient> m_chromeClient;
     std::unique_ptr<Page> m_page;
     FloatSize m_intrinsicSize;
+
+    Timer m_startAnimationTimer;
 };
 
 bool isInSVGImage(const Element*);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to