⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280601 in webkit


Ignore:
Timestamp:
Aug 3, 2021, 10:34:48 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Crash while reading WebGL drawing buffer if canvas image buffer allocation fails
https://bugs.webkit.org/show_bug.cgi?id=228737
<rdar://81150042>

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-08-03
Reviewed by Brent Fulgham.

Source/WebCore:

The crash would happen for example when running out of memory during snapshot
or printing. Snapshots and printing forces the WebGL canvas to be "painted
to document", which would then trigger the crash.

Other code-paths that invoke CanvasBase::makeRenderingResultsAvailable,
e.g. toDataURL and drawImage will check for the buffer before, and
as such are not testable in the sense that adding the test would trigger
the bug.

Test: webgl/webgl-oom-paint-document-no-crash.html

  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::paintRenderingResultsToCanvas):
Check for the nullptr from CanvasBase::buffer(). This might happen
when the ImageBuffer was not allocated due to memory constraints.

LayoutTests:

Add a test for failure to paint the WebGL canvas to document.
Trigger the mode by using printing.

Other code-paths that invoke CanvasBase::makeRenderingResultsAvailable,
e.g. toDataURL and drawImage will check for the buffer before, and
as such are not testable in the sense that adding the test would trigger
the bug.

  • webgl/webgl-oom-paint-document-no-crash-expected.html: Added.
  • webgl/webgl-oom-paint-document-no-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280599 r280601  
     12021-08-03  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        Crash while reading WebGL drawing buffer if canvas image buffer allocation fails
     4        https://bugs.webkit.org/show_bug.cgi?id=228737
     5        <rdar://81150042>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Add a test for failure to paint the WebGL canvas to document.
     10        Trigger the mode by using printing.
     11
     12        Other code-paths that invoke CanvasBase::makeRenderingResultsAvailable,
     13        e.g. toDataURL and drawImage will check for the buffer before, and
     14        as such are not testable in the sense that adding the test would trigger
     15        the bug.
     16
     17        * webgl/webgl-oom-paint-document-no-crash-expected.html: Added.
     18        * webgl/webgl-oom-paint-document-no-crash.html: Added.
     19
    1202021-08-03  Antti Koivisto  <antti@apple.com>
    221
  • trunk/Source/WebCore/ChangeLog

    r280599 r280601  
     12021-08-03  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        Crash while reading WebGL drawing buffer if canvas image buffer allocation fails
     4        https://bugs.webkit.org/show_bug.cgi?id=228737
     5        <rdar://81150042>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        The crash would happen for example when running out of memory during snapshot
     10        or printing. Snapshots and printing forces the WebGL canvas to be "painted
     11        to document", which would then trigger the crash.
     12
     13        Other code-paths that invoke CanvasBase::makeRenderingResultsAvailable,
     14        e.g. toDataURL and drawImage will check for the buffer before, and
     15        as such are not testable in the sense that adding the test would trigger
     16        the bug.
     17
     18        Test: webgl/webgl-oom-paint-document-no-crash.html
     19
     20        * html/canvas/WebGLRenderingContextBase.cpp:
     21        (WebCore::WebGLRenderingContextBase::paintRenderingResultsToCanvas):
     22        Check for the nullptr from CanvasBase::buffer(). This might happen
     23        when the ImageBuffer was not allocated due to memory constraints.
     24
    1252021-08-03  Antti Koivisto  <antti@apple.com>
    226
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r280587 r280601  
    12191219            base.clearCopiedImage();
    12201220            m_markedCanvasDirty = false;
    1221             // FIXME: Remote ImageBuffers do not flush the buffers that are drawn to a buffer.
    1222             // Avoid leaking the WebGL content in the cases where a WebGL canvas element is drawn to a Context2D
    1223             // canvas element repeatedly.
    1224             base.buffer()->flushDrawingContext();
    1225             m_context->paintCompositedResultsToCanvas(*base.buffer());
     1221            if (auto buffer = base.buffer()) {
     1222                // FIXME: Remote ImageBuffers do not flush the buffers that are drawn to a buffer.
     1223                // Avoid leaking the WebGL content in the cases where a WebGL canvas element is drawn to a Context2D
     1224                // canvas element repeatedly.
     1225                buffer->flushDrawingContext();
     1226                m_context->paintCompositedResultsToCanvas(*buffer);
     1227            }
    12261228        }
    12271229        return;
     
    12371239
    12381240    m_markedCanvasDirty = false;
    1239     // FIXME: Remote ImageBuffers do not flush the buffers that are drawn to a buffer.
    1240     // Avoid leaking the WebGL content in the cases where a WebGL canvas element is drawn to a Context2D
    1241     // canvas element repeatedly.
    1242     base.buffer()->flushDrawingContext();
    1243     m_context->paintRenderingResultsToCanvas(*base.buffer());
     1241    if (auto buffer = base.buffer()) {
     1242        // FIXME: Remote ImageBuffers do not flush the buffers that are drawn to a buffer.
     1243        // Avoid leaking the WebGL content in the cases where a WebGL canvas element is drawn to a Context2D
     1244        // canvas element repeatedly.
     1245        buffer->flushDrawingContext();
     1246        m_context->paintRenderingResultsToCanvas(*buffer);
     1247    }
    12441248}
    12451249
Note: See TracChangeset for help on using the changeset viewer.