Title: [278756] trunk
Revision
278756
Author
[email protected]
Date
2021-06-11 01:24:22 -0700 (Fri, 11 Jun 2021)

Log Message

WebGL context image buffer accumulates the NativeImage contents when drawn to RemoteImageBufferProxy
https://bugs.webkit.org/show_bug.cgi?id=226813
<rdar://77421966>

Patch by Kimmo Kinnunen <[email protected]> on 2021-06-11
Reviewed by Simon Fraser.

Source/WebCore:

Add a workaround to flush WebGL element image buffer before
every new frame in order to clear the WebContent process side
NativeImage caches.

Test: webgl/draw-webgl-to-context2d-memory-test.html

* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::paintRenderingResultsToCanvas):

LayoutTests:

Add a test that should crash on some devices with low
memory limits.

* webgl/draw-webgl-to-context2d-memory-test-expected.txt: Added.
* webgl/draw-webgl-to-context2d-memory-test.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (278755 => 278756)


--- trunk/LayoutTests/ChangeLog	2021-06-11 05:29:30 UTC (rev 278755)
+++ trunk/LayoutTests/ChangeLog	2021-06-11 08:24:22 UTC (rev 278756)
@@ -1,3 +1,17 @@
+2021-06-11  Kimmo Kinnunen  <[email protected]>
+
+        WebGL context image buffer accumulates the NativeImage contents when drawn to RemoteImageBufferProxy
+        https://bugs.webkit.org/show_bug.cgi?id=226813
+        <rdar://77421966>
+
+        Reviewed by Simon Fraser.
+
+        Add a test that should crash on some devices with low
+        memory limits.
+
+        * webgl/draw-webgl-to-context2d-memory-test-expected.txt: Added.
+        * webgl/draw-webgl-to-context2d-memory-test.html: Added.
+
 2021-06-10  Sam Weinig  <[email protected]>
 
         Nothing is keeping navigator.xr alive during GC

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (278755 => 278756)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2021-06-11 05:29:30 UTC (rev 278755)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2021-06-11 08:24:22 UTC (rev 278756)
@@ -95,6 +95,9 @@
 # to draw lots of nothing.
 webkit.org/b/209416 fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays.html [ Pass Timeout ]
 
+# Test is slow.
+webkit.org/b/226813 webgl/draw-webgl-to-context2d-memory-test.html [ Skip ]
+
 imported/w3c/web-platform-tests/css/css-lists/content-property/marker-text-matches-georgian.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-lists/content-property/marker-text-matches-lower-greek.html [ Pass ]
 imported/w3c/web-platform-tests/css/css-lists/list-and-writing-mode-001.html [ Failure ]

Added: trunk/LayoutTests/webgl/draw-webgl-to-context2d-memory-test-expected.txt (0 => 278756)


--- trunk/LayoutTests/webgl/draw-webgl-to-context2d-memory-test-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgl/draw-webgl-to-context2d-memory-test-expected.txt	2021-06-11 08:24:22 UTC (rev 278756)
@@ -0,0 +1,35 @@
+This test checking that drawing WebGL canvas to Context2D canvas with drawImage does not use unbounded amount of memory.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS drawImage: Should be [64, 128, 192, 255]
+PASS getError was expected value: NO_ERROR :
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webgl/draw-webgl-to-context2d-memory-test.html (0 => 278756)


--- trunk/LayoutTests/webgl/draw-webgl-to-context2d-memory-test.html	                        (rev 0)
+++ trunk/LayoutTests/webgl/draw-webgl-to-context2d-memory-test.html	2021-06-11 08:24:22 UTC (rev 278756)
@@ -0,0 +1,39 @@
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Canvas to Context2D Canvas Memory Test</title>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas2d" width="40" height="40"></canvas>
+<script>
+"use strict";
+description("This test checking that drawing WebGL canvas to Context2D canvas with drawImage does not use unbounded amount of memory.");
+var wtu = WebGLTestUtils;
+var canvas2d = document.getElementById("canvas2d");
+var ctx2d = canvas2d.getContext("2d");
+var canvasWebGL = document.createElement("canvas");
+canvasWebGL.width = 4000;
+canvasWebGL.height = 4000;
+var gl = wtu.create3DContext(canvasWebGL);
+if (!gl) {
+    testFailed("context does not exist");
+} else {
+    gl.clearColor(0.25, 0.5, 0.75, 1);
+    for (var count = 0; count < 25; count++) {
+        ctx2d.clearRect(0, 0, canvas2d.width, canvas2d.height);
+        gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+        ctx2d.drawImage(canvasWebGL, 0, 0, canvas2d.width, canvas2d.height);
+        wtu.checkCanvasRect(ctx2d, 0, 0, canvas2d.width, canvas2d.height, [64, 128, 192, 255], "drawImage: Should be [64, 128, 192, 255]", 2);
+    }
+    wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+    debug("");
+    finishTest();
+}
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (278755 => 278756)


--- trunk/Source/WebCore/ChangeLog	2021-06-11 05:29:30 UTC (rev 278755)
+++ trunk/Source/WebCore/ChangeLog	2021-06-11 08:24:22 UTC (rev 278756)
@@ -1,3 +1,20 @@
+2021-06-11  Kimmo Kinnunen  <[email protected]>
+
+        WebGL context image buffer accumulates the NativeImage contents when drawn to RemoteImageBufferProxy
+        https://bugs.webkit.org/show_bug.cgi?id=226813
+        <rdar://77421966>
+
+        Reviewed by Simon Fraser.
+
+        Add a workaround to flush WebGL element image buffer before
+        every new frame in order to clear the WebContent process side
+        NativeImage caches.
+
+        Test: webgl/draw-webgl-to-context2d-memory-test.html
+
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::paintRenderingResultsToCanvas):
+
 2021-06-10  Chris Dumez  <[email protected]>
 
         CARingBuffer::frameOffset() makes incorrect assumptions about the frame count

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (278755 => 278756)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2021-06-11 05:29:30 UTC (rev 278755)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2021-06-11 08:24:22 UTC (rev 278756)
@@ -1218,6 +1218,10 @@
             auto& base = canvasBase();
             base.clearCopiedImage();
             m_markedCanvasDirty = false;
+            // FIXME: Remote ImageBuffers do not flush the buffers that are drawn to a buffer.
+            // Avoid leaking the WebGL content in the cases where a WebGL canvas element is drawn to a Context2D
+            // canvas element repeatedly.
+            base.buffer()->flushDrawingContext();
             m_context->paintCompositedResultsToCanvas(*base.buffer());
         }
         return;
@@ -1232,7 +1236,10 @@
     base.clearCopiedImage();
 
     m_markedCanvasDirty = false;
-
+    // FIXME: Remote ImageBuffers do not flush the buffers that are drawn to a buffer.
+    // Avoid leaking the WebGL content in the cases where a WebGL canvas element is drawn to a Context2D
+    // canvas element repeatedly.
+    base.buffer()->flushDrawingContext();
     m_context->paintRenderingResultsToCanvas(*base.buffer());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to