- Revision
- 295132
- Author
- [email protected]
- Date
- 2022-06-02 11:13:50 -0700 (Thu, 02 Jun 2022)
Log Message
REGRESSION(r289580): Canvas: putImageData sometimes draws nothing
https://bugs.webkit.org/show_bug.cgi?id=240802
rdar://93801722
Reviewed by Simon Fraser.
RemoteImageBufferProxy::putPixelBuffer() needs to setNeedsFlush(true) once the
request to change the backend is sent to GPUProcess. If WebProcess has access to
the ImageBufferBackend, flushDrawingContext() will be called from copyNativeImage().
This call has to wait for all DisplayList items and PutPixelBuffer messages to be
flushed to the backend before copyNativeImage() copies the pixels of the backend
to a NativeImage.
* LayoutTests/fast/canvas/canvas-put-image-data-no-draw-expected.html: Added.
* LayoutTests/fast/canvas/canvas-put-image-data-no-draw.html: Added.
* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::Layout::FlexFormattingContext::convertFlexItemsToLogicalSpace):
* Source/WebCore/platform/graphics/ImageBuffer.h:
(WebCore::ImageBuffer::setNeedsFlush):
* Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:
(WebKit::RemoteDisplayListRecorderProxy::send):
(WebKit::RemoteDisplayListRecorderProxy::resetNeedsFlush): Deleted.
(WebKit::RemoteDisplayListRecorderProxy::needsFlush const): Deleted.
(): Deleted.
* Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
(WebKit::RemoteImageBufferProxy::~RemoteImageBufferProxy):
Canonical link: https://commits.webkit.org/251223@main
Modified Paths
Added Paths
Diff
Added: trunk/LayoutTests/fast/canvas/canvas-put-image-data-no-draw-expected.html (0 => 295132)
--- trunk/LayoutTests/fast/canvas/canvas-put-image-data-no-draw-expected.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-put-image-data-no-draw-expected.html 2022-06-02 18:13:50 UTC (rev 295132)
@@ -0,0 +1,13 @@
+<body>
+ <canvas id="target" width="400" height="400"></canvas>
+ <script>
+ const targetCanvas = document.getElementById('target');
+ const target = targetCanvas.getContext('2d');
+
+ const canvasWidth = targetCanvas.width;
+ const canvasHeight = targetCanvas.height
+
+ target.fillStyle = 'green';
+ target.fillRect(0, 0, canvasWidth, canvasHeight);
+ </script>
+</body>
Added: trunk/LayoutTests/fast/canvas/canvas-put-image-data-no-draw.html (0 => 295132)
--- trunk/LayoutTests/fast/canvas/canvas-put-image-data-no-draw.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-put-image-data-no-draw.html 2022-06-02 18:13:50 UTC (rev 295132)
@@ -0,0 +1,50 @@
+<body>
+ <canvas id="target" width="400" height="400"></canvas>
+ <script>
+ const targetCanvas = document.getElementById('target');
+ const target = targetCanvas.getContext('2d');
+
+ const canvasWidth = targetCanvas.width;
+ const canvasHeight = targetCanvas.height
+
+ var sourceCanvas = document.createElement('canvas');
+ sourceCanvas.width = canvasWidth;
+ sourceCanvas.height = canvasHeight;
+
+ const source = sourceCanvas.getContext('2d');
+
+ let progressX = 0;
+ let progressY = 0;
+ const paintSize = 100;
+
+ source.fillStyle = 'green';
+ source.fillRect(0, 0, canvasWidth, canvasHeight);
+ const imagedata = source.getImageData(0, 0, canvasWidth, canvasHeight);
+
+ function drawLoop() {
+ target.putImageData(imagedata, 0, 0, progressX, progressY, paintSize, paintSize);
+
+ progressX += paintSize;
+
+ if (progressX + paintSize <= canvasWidth) {
+ requestAnimationFrame(drawLoop);
+ return;
+ }
+
+ if (progressY + paintSize > canvasHeight) {
+ if (window.testRunner)
+ testRunner.notifyDone();
+ return;
+ }
+
+ progressX = 0;
+ progressY += paintSize;
+ requestAnimationFrame(drawLoop);
+ }
+
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ requestAnimationFrame(drawLoop);
+ </script>
+</body>
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (295131 => 295132)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2022-06-02 17:41:13 UTC (rev 295131)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2022-06-02 18:13:50 UTC (rev 295132)
@@ -1708,27 +1708,6 @@
webkit.org/b/240670 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-move-into-script-disabled-iframe.html [ Pass Crash ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance/textures/image_bitmap_from_image_bitmap/tex-2d-rgb-rgb-unsigned_short_5_6_5.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance/textures/image_bitmap_from_image_bitmap/tex-2d-rgba-rgba-unsigned_byte.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance/textures/image_bitmap_from_image_bitmap/tex-2d-rgba-rgba-unsigned_short_4_4_4_4.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-r11f_g11f_b10f-rgb-unsigned_int_10f_11f_11f_rev.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-r16f-red-float.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-r8-red-unsigned_byte.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-rgb5_a1-rgba-unsigned_short_5_5_5_1.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-3d-rgb16f-rgb-float.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-3d-rgb565-rgb-unsigned_short_5_6_5.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-3d-rgb9_e5-rgb-half_float.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-3d-rgba32f-rgba-float.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-3d-rgba8ui-rgba_integer-unsigned_byte.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-r32f-red-float.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-rgb8-rgb-unsigned_byte.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-rgb9_e5-rgb-float.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-rgba4-rgba-unsigned_byte.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-3d-rgb16f-rgb-half_float.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-3d-srgb8-rgb-unsigned_byte.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-r11f_g11f_b10f-rgb-float.html [ Pass Failure ]
-webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-r16f-red-half_float.html [ Pass Failure ]
-
webkit.org/b/240821 [ Monterey Release ] webgl/max-active-contexts-webglcontextlost-prevent-default.html [ Slow ]
webkit.org/b/240830 [ Monterey ] webgl/2.0.0/conformance/attribs/gl-vertexattribpointer-offsets.html [ Pass Timeout ]
Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (295131 => 295132)
--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h 2022-06-02 17:41:13 UTC (rev 295131)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h 2022-06-02 18:13:50 UTC (rev 295132)
@@ -100,6 +100,7 @@
virtual void flushDrawingContext() { }
virtual bool flushDrawingContextAsync() { return false; }
virtual void didFlush(GraphicsContextFlushIdentifier) { }
+ virtual void setNeedsFlush(bool) { }
virtual FloatSize logicalSize() const = 0;
virtual IntSize truncatedLogicalSize() const = 0; // This truncates the real size. You probably should be calling logicalSize() instead.
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h (295131 => 295132)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h 2022-06-02 17:41:13 UTC (rev 295131)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h 2022-06-02 18:13:50 UTC (rev 295132)
@@ -42,9 +42,6 @@
RemoteDisplayListRecorderProxy(WebCore::ImageBuffer&, RemoteRenderingBackendProxy&, const WebCore::FloatRect& initialClip, const WebCore::AffineTransform&);
~RemoteDisplayListRecorderProxy() = default;
- void resetNeedsFlush() { m_needsFlush = false; }
- bool needsFlush() const { return m_needsFlush; }
-
void convertToLuminanceMask() final;
void transformToColorSpace(const WebCore::DestinationColorSpace&) final;
void flushContext(WebCore::GraphicsContextFlushIdentifier);
@@ -53,10 +50,10 @@
template<typename T>
void send(T&& message)
{
- if (UNLIKELY(!m_renderingBackend))
+ if (UNLIKELY(!(m_renderingBackend && m_imageBuffer)))
return;
- m_needsFlush = true;
+ m_imageBuffer->setNeedsFlush(true);
m_renderingBackend->sendToStream(WTFMove(message), m_destinationBufferIdentifier);
}
@@ -144,7 +141,6 @@
WebCore::RenderingResourceIdentifier m_destinationBufferIdentifier;
WeakPtr<WebCore::ImageBuffer> m_imageBuffer;
WeakPtr<RemoteRenderingBackendProxy> m_renderingBackend;
- bool m_needsFlush { false };
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (295131 => 295132)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2022-06-02 17:41:13 UTC (rev 295131)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2022-06-02 18:13:50 UTC (rev 295132)
@@ -66,7 +66,7 @@
~RemoteImageBufferProxy()
{
if (!m_remoteRenderingBackendProxy || m_remoteRenderingBackendProxy->isGPUProcessConnectionClosed()) {
- m_remoteDisplayList.resetNeedsFlush();
+ setNeedsFlush(false);
return;
}
@@ -116,6 +116,11 @@
m_receivedFlushIdentifierChangedCondition.notifyAll();
}
+ void setNeedsFlush(bool needsFlush) final
+ {
+ m_needsFlush = needsFlush;
+ }
+
void waitForDidFlushWithTimeout()
{
if (!m_remoteRenderingBackendProxy)
@@ -246,7 +251,7 @@
void clearBackend() final
{
- m_remoteDisplayList.resetNeedsFlush();
+ setNeedsFlush(false);
didFlush(m_sentFlushIdentifier);
BaseConcreteImageBuffer::clearBackend();
}
@@ -271,6 +276,7 @@
auto& mutableThis = const_cast<RemoteImageBufferProxy&>(*this);
mutableThis.flushDrawingContextAsync();
m_remoteRenderingBackendProxy->putPixelBufferForImageBuffer(m_renderingResourceIdentifier, pixelBuffer, srcRect, destPoint, destFormat);
+ setNeedsFlush(true);
}
void convertToLuminanceMask() final
@@ -309,13 +315,13 @@
if (UNLIKELY(!m_remoteRenderingBackendProxy))
return false;
- if (!m_remoteDisplayList.needsFlush())
+ if (!m_needsFlush)
return hasPendingFlush();
m_sentFlushIdentifier = WebCore::GraphicsContextFlushIdentifier::generate();
LOG_WITH_STREAM(SharedDisplayLists, stream << "RemoteImageBufferProxy " << m_renderingResourceIdentifier << " flushDrawingContextAsync - flush " << m_sentFlushIdentifier);
m_remoteDisplayList.flushContext(m_sentFlushIdentifier);
- m_remoteDisplayList.resetNeedsFlush();
+ setNeedsFlush(false);
return true;
}
@@ -348,6 +354,7 @@
WebCore::GraphicsContextFlushIdentifier m_receivedFlushIdentifier WTF_GUARDED_BY_LOCK(m_receivedFlushIdentifierLock); // Only modified on the main thread but may get queried on a secondary thread.
WeakPtr<RemoteRenderingBackendProxy> m_remoteRenderingBackendProxy;
RemoteDisplayListRecorderProxy m_remoteDisplayList;
+ bool m_needsFlush { false };
};
template<typename BackendType>