ASSERTION FAILED: !canAnimate() && !m_currentFrame
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 17:28:20 +0000 (17:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 17:28:20 +0000 (17:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173089

Patch by Fujii Hironori <Hironori.Fujii@sony.com> on 2017-06-30
Reviewed by Said Abou-Hallawa.

Source/WebCore:

WebCore::BitmapImage::draw() has an assertion which ensures
m_currentFrame is zero in case of async decoding. But, this
assertion failed if an GIF animation image which have finished its
animation was repainted. In that time, m_currentFrame was the last
frame index of the image.

Test: fast/images/animated-gif-paint-after-animation.html

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::draw): Assert m_currentFrame is zero or the animation finished.
Call requestFrameAsyncDecodingAtIndex with m_currentFrame instead of zero.

LayoutTests:

* fast/images/animated-gif-paint-after-animation-expected.txt: Added.
* fast/images/animated-gif-paint-after-animation.html: Added.
* fast/images/resources/animated-red-green-1000x1000-repeat-1.gif: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219003 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/images/animated-gif-paint-after-animation-expected.txt [new file with mode: 0644]
LayoutTests/fast/images/animated-gif-paint-after-animation.html [new file with mode: 0644]
LayoutTests/fast/images/resources/animated-red-green-1000x1000-repeat-1.gif [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/BitmapImage.cpp

index 7bd8650..300465a 100644 (file)
@@ -1,3 +1,14 @@
+2017-06-30  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        ASSERTION FAILED: !canAnimate() && !m_currentFrame
+        https://bugs.webkit.org/show_bug.cgi?id=173089
+
+        Reviewed by Said Abou-Hallawa.
+
+        * fast/images/animated-gif-paint-after-animation-expected.txt: Added.
+        * fast/images/animated-gif-paint-after-animation.html: Added.
+        * fast/images/resources/animated-red-green-1000x1000-repeat-1.gif: Added.
+
 2017-06-30  John Wilander  <wilander@apple.com>
 
         Update expectations for layout tests.
diff --git a/LayoutTests/fast/images/animated-gif-paint-after-animation-expected.txt b/LayoutTests/fast/images/animated-gif-paint-after-animation-expected.txt
new file mode 100644 (file)
index 0000000..122ffde
--- /dev/null
@@ -0,0 +1 @@
+PASS if no assertion failure  
diff --git a/LayoutTests/fast/images/animated-gif-paint-after-animation.html b/LayoutTests/fast/images/animated-gif-paint-after-animation.html
new file mode 100644 (file)
index 0000000..9b86f65
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals && window.testRunner) {
+        internals.clearMemoryCache();
+        internals.settings.setLargeImageAsyncDecodingEnabled(true);
+        internals.settings.setWebkitImageReadyEventEnabled(true);
+        testRunner.dumpAsText(true);
+        testRunner.waitUntilDone();
+    }
+</script>
+</head>
+<body>
+    PASS if no assertion failure
+    <img>
+    <script>
+        var img = document.getElementsByTagName('img')[0];
+        img.onload = function() {
+            // Force layout and display so the image frame starts decoding.
+            document.body.offsetHeight;
+            if (window.testRunner)
+                testRunner.display();
+        }
+        img.addEventListener("webkitImageFrameReady", function() {
+            // Force the page to be displayed. The image element is already invalidated when the frame finished decoding.
+            if (window.testRunner)
+                testRunner.display();
+            // Change the width of the img element
+            img.width = "100";
+            // notifyDone() will force the last layout and display.
+            if (window.testRunner)
+                testRunner.notifyDone();
+        });
+        img.src = 'resources/animated-red-green-1000x1000-repeat-1.gif';
+    </script>
+</body>
+</html>
diff --git a/LayoutTests/fast/images/resources/animated-red-green-1000x1000-repeat-1.gif b/LayoutTests/fast/images/resources/animated-red-green-1000x1000-repeat-1.gif
new file mode 100644 (file)
index 0000000..9a52a2f
Binary files /dev/null and b/LayoutTests/fast/images/resources/animated-red-green-1000x1000-repeat-1.gif differ
index 528f351..223458e 100644 (file)
@@ -1,3 +1,22 @@
+2017-06-30  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        ASSERTION FAILED: !canAnimate() && !m_currentFrame
+        https://bugs.webkit.org/show_bug.cgi?id=173089
+
+        Reviewed by Said Abou-Hallawa.
+
+        WebCore::BitmapImage::draw() has an assertion which ensures
+        m_currentFrame is zero in case of async decoding. But, this
+        assertion failed if an GIF animation image which have finished its
+        animation was repainted. In that time, m_currentFrame was the last
+        frame index of the image.
+
+        Test: fast/images/animated-gif-paint-after-animation.html
+
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::draw): Assert m_currentFrame is zero or the animation finished.
+        Call requestFrameAsyncDecodingAtIndex with m_currentFrame instead of zero.
+
 2017-06-30  Ross Kirsling  <ross.kirsling@sony.com>
 
         [PAL] Move Sound into PAL
index 1d3fabb..494144a 100644 (file)
@@ -191,7 +191,8 @@ void BitmapImage::draw(GraphicsContext& context, const FloatRect& destRect, cons
 
     NativeImagePtr image;
     if (decodingMode == DecodingMode::Asynchronous && shouldUseAsyncDecodingForLargeImages()) {
-        ASSERT(!canAnimate() && !m_currentFrame);
+        ASSERT(!canAnimate());
+        ASSERT(!m_currentFrame || m_animationFinished);
 
         bool frameIsCompatible = frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(m_currentFrame, m_currentSubsamplingLevel, DecodingOptions(sizeForDrawing));
         bool frameIsBeingDecoded = frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(m_currentFrame, DecodingOptions(sizeForDrawing));
@@ -200,7 +201,7 @@ void BitmapImage::draw(GraphicsContext& context, const FloatRect& destRect, cons
         // it is currently being decoded. New data may have been received since the previous request was made.
         if ((!frameIsCompatible && !frameIsBeingDecoded) || m_currentFrameDecodingStatus == ImageFrame::DecodingStatus::Invalid) {
             LOG(Images, "BitmapImage::%s - %p - url: %s [requesting large async decoding]", __FUNCTION__, this, sourceURL().string().utf8().data());
-            m_source.requestFrameAsyncDecodingAtIndex(0, m_currentSubsamplingLevel, sizeForDrawing);
+            m_source.requestFrameAsyncDecodingAtIndex(m_currentFrame, m_currentSubsamplingLevel, sizeForDrawing);
             m_currentFrameDecodingStatus = ImageFrame::DecodingStatus::Decoding;
         }