Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 48db7480703cf267922ad0b91f1ef965d8fa64a4
https://github.com/WebKit/WebKit/commit/48db7480703cf267922ad0b91f1ef965d8fa64a4
Author: Nikolas Zimmermann <[email protected]>
Date: 2025-12-18 (Thu, 18 Dec 2025)
Changed paths:
M Source/WebCore/bindings/js/SerializedScriptValue.cpp
M Source/WebCore/html/ImageBitmap.cpp
M Source/WebCore/html/ImageBitmap.h
M Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp
M Source/WebCore/platform/graphics/ImageBuffer.cpp
M Source/WebCore/platform/graphics/ImageBuffer.h
M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h
M
Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp
M Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.h
Log Message:
-----------
REGRESSION(287399@main): [Skia] Broke rendering of various PDFs
https://bugs.webkit.org/show_bug.cgi?id=295538
Reviewed by Carlos Garcia Campos.
Fix PDF rendering regression caused by cross-thread transfer of accelerated
ImageBitmap. When a texture-backed image is transferred across threads, the
GPU texture may not be valid for the current Skia context.
The fix has two parts:
1. Flush GPU commands before cross-thread transfer by calling
flushDrawingContext() in
OffscreenCanvasRenderingContext2D::transferToImageBuffer().
This is implemented via ImageBufferSkiaAcceleratedBackend::flushContext()
which creates a GL fence and performs a server wait.
2. Rewrap textures at draw time in GraphicsContextSkia::drawNativeImage().
When drawing a texture-backed image, check if it's valid for the current
GrContext using isValid(). If not (because it was created in a different
thread/context), use SkImages::BorrowTextureFrom() to create a new SkImage
wrapper around the existing backend texture. Before rewrapping, create
a GL fence and server wait to ensure pending GPU operations on the source
image are complete.
This approach simplifies cross-thread transfer by removing the explicit
prepare/finalize pattern from ImageBitmap (prepareForCrossThreadTransfer,
finalizeCrossThreadTransfer, m_fence member), ImageBuffer
(sinkIntoImageBufferForCrossThreadTransfer,
sinkIntoImageBufferAfterCrossThreadTransfer), and SerializedScriptValue.
Also refactor the fence creation API: rename the implementation to
createAcceleratedRenderingFenceInternal, add public static
createAcceleratedRenderingFence() methods for both SkSurface* and
sk_sp<SkImage>, and remove the private createAcceleratedRenderingFenceIfNeeded
methods by inlining the null/texture-backed checks into callers.
Covered by existing tests.
* Source/WebCore/bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpImageBitmap):
(WebCore::CloneDeserializer::readTransferredImageBitmap):
* Source/WebCore/html/ImageBitmap.cpp:
(WebCore::ImageBitmap::prepareForCrossThreadTransfer): Deleted.
(WebCore::ImageBitmap::finalizeCrossThreadTransfer): Deleted.
* Source/WebCore/html/ImageBitmap.h:
* Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp:
(WebCore::OffscreenCanvasRenderingContext2D::transferToImageBuffer):
* Source/WebCore/platform/graphics/ImageBuffer.cpp:
(WebCore::DefaultSerializedImageBuffer::DefaultSerializedImageBuffer):
(WebCore::ImageBuffer::sinkIntoImageBufferForCrossThreadTransfer): Deleted.
(WebCore::ImageBuffer::sinkIntoImageBufferAfterCrossThreadTransfer): Deleted.
* Source/WebCore/platform/graphics/ImageBuffer.h:
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContextSkia::drawNativeImage):
(WebCore::createAcceleratedRenderingFenceInternal):
(WebCore::GraphicsContextSkia::createAcceleratedRenderingFence):
(WebCore::GraphicsContextSkia::trackAcceleratedRenderingFenceIfNeeded):
(WebCore::createAcceleratedRenderingFence): Deleted.
(WebCore::GraphicsContextSkia::createAcceleratedRenderingFenceIfNeeded):
Deleted.
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h:
* Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp:
(WebCore::ImageBufferSkiaAcceleratedBackend::flushContext):
* Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.h:
Canonical link: https://commits.webkit.org/304687@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications