[webkit-changes] [WebKit/WebKit] c83035: CanvasBase::makeRenderingResultsAvailable is not c...

Kimmo Kinnunen noreply at github.com
Wed May 22 23:51:55 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c83035adb300082d800e687be6b3d0517d132cbb
      https://github.com/WebKit/WebKit/commit/c83035adb300082d800e687be6b3d0517d132cbb
  Author: Kimmo Kinnunen <kkinnunen at apple.com>
  Date:   2024-05-22 (Wed, 22 May 2024)

  Changed paths:
    M Source/WebCore/Modules/WebGPU/GPUQueue.cpp
    M Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.cpp
    M Source/WebCore/html/CanvasBase.cpp
    M Source/WebCore/html/CanvasBase.h
    M Source/WebCore/html/HTMLCanvasElement.cpp
    M Source/WebCore/html/OffscreenCanvas.cpp
    M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
    M Source/WebCore/rendering/style/StyleCanvasImage.cpp

  Log Message:
  -----------
  CanvasBase::makeRenderingResultsAvailable is not called consistently
https://bugs.webkit.org/show_bug.cgi?id=274517
rdar://128533924

Reviewed by Matt Woodrow.

Inconsistencies:
 - Sometimes buffer() is accessed after the call to makeRenderingResultsAvailable
   This is the intended correct operation.
 - Sometimes buffer() is accessed before the call to makeRenderingResultsAvailable
 - Sometimes buffer() is accessed without the call to makeRenderingResultsAvailable

makeRenderingResultsAvailable() intention is to force rendering results to be
written to the CanvasBase::m_imageBuffer. This includes sometimes applying the
anti-fingerprint noise.

Accessing buffer() before the call prevents makeRenderingResultsAvailable()
being able to replace the internal buffer in future commits.

Accessing buffer() without the call does not guarantee that the rendering
is present in the buffer, for example with WebGL. Also it it does not
apply the potential anti-fingerprint noise.

Fix by:
When HTMLCanvasElement and OffscreenCanvas are used as image source,
call makeRenderingResultsAvailable() to obtain the buffer.
Returning the buffer from makeRenderingResultsAvailable() makes it easier
to understand the access pattern.

This way future work can:
 - Swap the whole buffer when rendering results are read. This will be
   used in WebGL / WebGPU code.
 - Move the backing buffer logic to the respective rendering context
   implementation, where it belongs.

* Source/WebCore/Modules/WebGPU/GPUQueue.cpp:
(WebCore::getImageBytesFromImageBuffer):
(WebCore::imageBytesForSource):
* Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.cpp:
(WebCore::WebCodecsVideoFrame::create):
* Source/WebCore/html/CanvasBase.cpp:
(WebCore::CanvasBase::makeRenderingResultsAvailable):
* Source/WebCore/html/CanvasBase.h:
* Source/WebCore/html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::toDataURL):
(WebCore::HTMLCanvasElement::toBlob):
(WebCore::HTMLCanvasElement::toVideoFrame):
(WebCore::HTMLCanvasElement::copiedImage const):
* Source/WebCore/html/OffscreenCanvas.cpp:
(WebCore::OffscreenCanvas::convertToBlob):
(WebCore::OffscreenCanvas::copiedImage const):
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::drawImage):
(WebCore::CanvasRenderingContext2DBase::getImageData const):
* Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::validateHTMLCanvasElement):
(WebCore::WebGLRenderingContextBase::validateOffscreenCanvas):
* Source/WebCore/inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::indexForData):
* Source/WebCore/rendering/style/StyleCanvasImage.cpp:
(WebCore::StyleCanvasImage::image const):

Canonical link: https://commits.webkit.org/279184@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list