Title: [282931] branches/safari-612-branch/Source/WebCore
Revision
282931
Author
repst...@apple.com
Date
2021-09-22 22:13:45 -0700 (Wed, 22 Sep 2021)

Log Message

Cherry-pick r281839. rdar://problem/83429771

    [GPU Process](REGRESSION): A detached canvas leaks all the images it draws
    https://bugs.webkit.org/show_bug.cgi?id=229668
    <rdar://problem/82532484>

    Reviewed by Simon Fraser.

    Before drawing the canvas to the page, the canvas element may need to
    prepare its context for display. For 2D canvas elements, this should
    happen regardless whether they are attached to the Document or not.
    Because prepareForDisplay() calls ImageBuffer::flushDrawingContextAsync(),
    this will ensure the canvas drawing commands are pushed from WebProcess
    to GPUProcess. It will also release the cached shared images from both
    WebProcess and GPUProcess.

    Move the decision to skip the context prepareForDisplay() step from
    Document::prepareCanvasesForDisplayIfNeeded() to
    WebGLRenderingContextBase::prepareForDisplay().

    * dom/Document.cpp:
    (WebCore::Document::prepareCanvasesForDisplayIfNeeded):
    * html/canvas/WebGLRenderingContextBase.cpp:
    (WebCore::WebGLRenderingContextBase::prepareForDisplay):

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

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (282930 => 282931)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-23 05:13:42 UTC (rev 282930)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-23 05:13:45 UTC (rev 282931)
@@ -1,5 +1,60 @@
 2021-09-22  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r281839. rdar://problem/83429771
+
+    [GPU Process](REGRESSION): A detached canvas leaks all the images it draws
+    https://bugs.webkit.org/show_bug.cgi?id=229668
+    <rdar://problem/82532484>
+    
+    Reviewed by Simon Fraser.
+    
+    Before drawing the canvas to the page, the canvas element may need to
+    prepare its context for display. For 2D canvas elements, this should
+    happen regardless whether they are attached to the Document or not.
+    Because prepareForDisplay() calls ImageBuffer::flushDrawingContextAsync(),
+    this will ensure the canvas drawing commands are pushed from WebProcess
+    to GPUProcess. It will also release the cached shared images from both
+    WebProcess and GPUProcess.
+    
+    Move the decision to skip the context prepareForDisplay() step from
+    Document::prepareCanvasesForDisplayIfNeeded() to
+    WebGLRenderingContextBase::prepareForDisplay().
+    
+    * dom/Document.cpp:
+    (WebCore::Document::prepareCanvasesForDisplayIfNeeded):
+    * html/canvas/WebGLRenderingContextBase.cpp:
+    (WebCore::WebGLRenderingContextBase::prepareForDisplay):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281839 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-01  Said Abou-Hallawa  <s...@apple.com>
+
+            [GPU Process](REGRESSION): A detached canvas leaks all the images it draws
+            https://bugs.webkit.org/show_bug.cgi?id=229668
+            <rdar://problem/82532484>
+
+            Reviewed by Simon Fraser.
+
+            Before drawing the canvas to the page, the canvas element may need to
+            prepare its context for display. For 2D canvas elements, this should
+            happen regardless whether they are attached to the Document or not.
+            Because prepareForDisplay() calls ImageBuffer::flushDrawingContextAsync(),
+            this will ensure the canvas drawing commands are pushed from WebProcess
+            to GPUProcess. It will also release the cached shared images from both
+            WebProcess and GPUProcess.
+
+            Move the decision to skip the context prepareForDisplay() step from
+            Document::prepareCanvasesForDisplayIfNeeded() to
+            WebGLRenderingContextBase::prepareForDisplay().
+
+            * dom/Document.cpp:
+            (WebCore::Document::prepareCanvasesForDisplayIfNeeded):
+            * html/canvas/WebGLRenderingContextBase.cpp:
+            (WebCore::WebGLRenderingContextBase::prepareForDisplay):
+
+2021-09-22  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r281691. rdar://problem/83429796
 
     Make AXCoreObject::setSelectedVisiblePositionRange work in native text controls on MacOS.

Modified: branches/safari-612-branch/Source/WebCore/dom/Document.cpp (282930 => 282931)


--- branches/safari-612-branch/Source/WebCore/dom/Document.cpp	2021-09-23 05:13:42 UTC (rev 282930)
+++ branches/safari-612-branch/Source/WebCore/dom/Document.cpp	2021-09-23 05:13:45 UTC (rev 282931)
@@ -8928,15 +8928,8 @@
 
     auto canvases = copyToVectorOf<Ref<HTMLCanvasElement>>(m_canvasesNeedingDisplayPreparation);
     m_canvasesNeedingDisplayPreparation.clear();
-    for (auto& canvas : canvases) {
-        // However, if they are not in the document body, then they won't
-        // be composited and thus don't need preparation. Unfortunately they
-        // can't tell at the time they were added to the list, since they
-        // could be inserted or removed from the document body afterwards.
-        if (!canvas->isInTreeScope())
-            continue;
+    for (auto& canvas : canvases)
         canvas->prepareForDisplay();
-    }
 }
 
 void Document::clearCanvasPreparation(HTMLCanvasElement& canvas)

Modified: branches/safari-612-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (282930 => 282931)


--- branches/safari-612-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2021-09-23 05:13:42 UTC (rev 282930)
+++ branches/safari-612-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2021-09-23 05:13:45 UTC (rev 282931)
@@ -8038,6 +8038,14 @@
     if (!m_context)
         return;
 
+    // If the canvas is not in the document body, then it won't be
+    // composited and thus doesn't need preparation. Unfortunately
+    // it can't tell at the time it was added to the list, since it
+    // could be inserted or removed from the document body afterwards.
+    auto canvas = htmlCanvas();
+    if (!canvas || !canvas->isInTreeScope())
+        return;
+
     m_context->prepareForDisplay();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to