Title: [258930] trunk/LayoutTests
Revision
258930
Author
[email protected]
Date
2020-03-24 12:40:24 -0700 (Tue, 24 Mar 2020)

Log Message

[ macOS ] fast/images/slower-decoding-than-animation-image.html is flaky failing
https://bugs.webkit.org/show_bug.cgi?id=207859

Patch by Said Abou-Hallawa <[email protected]> on 2020-03-24
Reviewed by Simon Fraser.

Instead of using setTimeout() to time the drawing of the animated image
frames, we will listen to the internal event 'webkitImageFrameReady' which
fires after the decoding of a frame finishes.

* fast/images/slower-decoding-than-animation-image-expected.txt:
* fast/images/slower-decoding-than-animation-image.html:
* platform/ios/TestExpectations:
* platform/mac-wk2/TestExpectations:
* platform/mac/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (258929 => 258930)


--- trunk/LayoutTests/ChangeLog	2020-03-24 19:36:23 UTC (rev 258929)
+++ trunk/LayoutTests/ChangeLog	2020-03-24 19:40:24 UTC (rev 258930)
@@ -1,3 +1,20 @@
+2020-03-24  Said Abou-Hallawa  <[email protected]>
+
+        [ macOS ] fast/images/slower-decoding-than-animation-image.html is flaky failing
+        https://bugs.webkit.org/show_bug.cgi?id=207859
+
+        Reviewed by Simon Fraser.
+
+        Instead of using setTimeout() to time the drawing of the animated image
+        frames, we will listen to the internal event 'webkitImageFrameReady' which
+        fires after the decoding of a frame finishes.
+
+        * fast/images/slower-decoding-than-animation-image-expected.txt:
+        * fast/images/slower-decoding-than-animation-image.html:
+        * platform/ios/TestExpectations:
+        * platform/mac-wk2/TestExpectations:
+        * platform/mac/TestExpectations:
+
 2020-03-23  Ryosuke Niwa  <[email protected]>
 
         [ macOS iOS ] fast/parser/parser-yield-timing.html is a flaky failure

Modified: trunk/LayoutTests/fast/images/slower-decoding-than-animation-image-expected.txt (258929 => 258930)


--- trunk/LayoutTests/fast/images/slower-decoding-than-animation-image-expected.txt	2020-03-24 19:36:23 UTC (rev 258929)
+++ trunk/LayoutTests/fast/images/slower-decoding-than-animation-image-expected.txt	2020-03-24 19:40:24 UTC (rev 258930)
@@ -3,8 +3,10 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS internals.imageFrameIndex(image) is 0
 PASS internals.imageFrameIndex(image) is 1
+PASS internals.imageFrameIndex(image) is 2
 PASS successfullyParsed is true
 
 TEST COMPLETE
-
+ 

Modified: trunk/LayoutTests/fast/images/slower-decoding-than-animation-image.html (258929 => 258930)


--- trunk/LayoutTests/fast/images/slower-decoding-than-animation-image.html	2020-03-24 19:36:23 UTC (rev 258929)
+++ trunk/LayoutTests/fast/images/slower-decoding-than-animation-image.html	2020-03-24 19:40:24 UTC (rev 258930)
@@ -4,52 +4,63 @@
     <script src=""
 </head>
 <body>
+    <img id="image">
     <canvas id="canvas"></canvas>
     <script>
-        description("Ensure the image frame is drawn when it finishes decoding even if it takes more than the previous frame duration.");
-        jsTestIsAsync = true;
+        function drawFrame(image, canvas, frameIndex) {
+            return new Promise((resolve) => {
+                let context = canvas.getContext("2d");
+                context.drawImage(image, 0, 0, 100, 100, 0, 0, canvas.width, canvas.height);
 
-        if (window.internals) {
-            internals.settings.setAnimatedImageDebugCanvasDrawingEnabled(true);
-            internals.clearMemoryCache();
+                if (window.internals) {
+                    shouldBe("internals.imageFrameIndex(image)", frameIndex.toString());
+                    image.addEventListener("webkitImageFrameReady", function() {
+                        resolve();
+                    }, false);
+                } else {
+                    setTimeout(() => {
+                        resolve();
+                    }, 40);
+                }
+            });
         }
 
-        var image = new Image;
-        image._onload_ = imageLoaded;
-        image.src = ""
+        function drawImage(image, canvas, frameCount) {
+            let promise = drawFrame(image, canvas, 0);
+            for (let frameIndex = 1; frameIndex < frameCount; ++frameIndex) {
+                promise = promise.then(() => {
+                    return drawFrame(image, canvas, frameIndex);
+                });
+            }
+            return promise;
+        }
 
-        function imageLoaded()
-        {
-            if (!window.internals)
-                return;
-            internals.setImageFrameDecodingDuration(image, 0.050);
-            drawImage();
-            drawLoop();
+        function loadImage(image, src, canvas, frameCount) {
+            return new Promise((resolve) => {
+                image._onload_ = (() => {
+                    if (window.internals) {
+                        internals.clearMemoryCache();
+                        internals.setImageFrameDecodingDuration(image, 0.050);
+                        internals.settings.setAnimatedImageDebugCanvasDrawingEnabled(true);
+                        internals.settings.setWebkitImageReadyEventEnabled(true);
+                    }
+                    drawImage(image, canvas, frameCount).then(resolve);
+                });
+                image.src = ""
+            });
         }
 
-        function drawImage()
-        {
-            if (drawImage.count == undefined)
-                drawImage.count = 0;
+        (function() {
+            description("Ensure the image frame is drawn when it finishes decoding even if it takes more than the previous frame duration.");
+            jsTestIsAsync = true;
+
+            var image = document.getElementById("image");
             var canvas = document.getElementById("canvas");
-            var ctx = canvas.getContext("2d");
-            ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
-            return ++drawImage.count;
-        }
-                
-        function drawLoop()
-        {
-            // 1st time the image is drawn, time = 0, current_frame = 0
-            // 2nd time the image is drawn, time = 40, current_frame = 0
-            // 3rd time the image is drawn, time = 80, current_frame = 1
-            setTimeout(function() {
-                if (drawImage() == 3) {
-                    shouldBe("internals.imageFrameIndex(image)", "1");
-                    finishJSTest();
-                } else
-                    drawLoop();
-            }, 40);
-        }
+
+            loadImage(image, "resources/animated-red-green-blue.gif", canvas, 3).then(() => {
+                finishJSTest();
+            });
+        })();
     </script>
     <script src=""
 </body>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (258929 => 258930)


--- trunk/LayoutTests/platform/ios/TestExpectations	2020-03-24 19:36:23 UTC (rev 258929)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2020-03-24 19:40:24 UTC (rev 258930)
@@ -2807,7 +2807,6 @@
 canvas/philip/tests/2d.drawImage.animated.gif.html [ Failure ]
 canvas/philip/tests/2d.pattern.animated.gif.html [ Failure ]
 fast/images/slower-animation-than-decoding-image.html [ Failure ]
-fast/images/slower-decoding-than-animation-image.html [ Failure ]
 fast/images/reset-image-animation.html [ Failure ]
 fast/images/animated-gif-loop-count.html [ ImageOnlyFailure ]
 fast/images/animated-png-loop-count.html [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (258929 => 258930)


--- trunk/LayoutTests/platform/mac/TestExpectations	2020-03-24 19:36:23 UTC (rev 258929)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2020-03-24 19:40:24 UTC (rev 258930)
@@ -1975,8 +1975,6 @@
 
 webkit.org/b/207726 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/security.pattern.fillStyle.sub.html [ Pass Failure ]
 
-webkit.org/b/207859 fast/images/slower-decoding-than-animation-image.html [ Pass Failure ]
-
 webkit.org/b/207858 fast/canvas/webgl/program-test.html [ Failure ]
 webkit.org/b/207858 webgl/1.0.3/conformance/programs/program-test.html [ Failure ]
 

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (258929 => 258930)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2020-03-24 19:36:23 UTC (rev 258929)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2020-03-24 19:40:24 UTC (rev 258930)
@@ -650,8 +650,6 @@
 
 webkit.org/b/172454 http/tests/navigation/statistics.html [ Pass Failure ]
 
-webkit.org/b/172666 [ Debug ] fast/images/slower-decoding-than-animation-image.html [ Pass Failure ]
-
 webkit.org/b/173188 fast/mediastream/getUserMedia-grant-persistency3.html [ Pass Failure ]
 
 webkit.org/b/172201 webaudio/silent-audio-interrupted-in-background.html [ Pass Timeout ]
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to