Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 827b5833cabfb4d2444d2c4da95c8489fd4fcdc3
      
https://github.com/WebKit/WebKit/commit/827b5833cabfb4d2444d2c4da95c8489fd4fcdc3
  Author: Kimmo Kinnunen <[email protected]>
  Date:   2025-10-01 (Wed, 01 Oct 2025)

  Changed paths:
    M Source/WebCore/platform/graphics/Gradient.cpp
    M Source/WebCore/platform/graphics/NativeImage.cpp
    M Source/WebCore/platform/graphics/NativeImage.h
    M Source/WebCore/platform/graphics/RenderingResource.h
    M Source/WebCore/platform/graphics/cg/NativeImageCG.cpp
    M Source/WebCore/platform/graphics/displaylists/DisplayList.cpp
    M Source/WebCore/platform/graphics/filters/FilterFunction.cpp
    M Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.cpp
    M Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h
    M Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.messages.in
    M Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp
    M Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h
    M Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in
    M Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp
    M Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h
    M Source/WebKit/Sources.txt
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.cpp
    M Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h
    A Source/WebKit/WebProcess/GPU/graphics/RemoteNativeImageProxy.cpp
    A Source/WebKit/WebProcess/GPU/graphics/RemoteNativeImageProxy.h
    M Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp
    M Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h
    M Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp
    M Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h

  Log Message:
  -----------
  NativeImages are slow to create from remote contexts
https://bugs.webkit.org/show_bug.cgi?id=266215
rdar://119489233

Reviewed by Matt Woodrow.

RemoteImageBufferProxy::copyNativeImage() would transfer the rendering
from GPUP to WCP. This was slow, and in turn lead to introduction of
ImageBuffer as a source for all types of bitmap draws, since this
resource exist in GPUP. This in turn is problematic, as ImageBuffers
are inherently mutable and as such cannot be shared. ImageBuffer is
a draw target type of abstraction, where as NativeImage is draw source
type of abstraction.

Fix this by implementing RemoteImageBufferProxy::copyNativeImage()
as a command that creates the NativeImage in GPUP and returns a
RemoteNativeImageProxy for WCP code. The image is
constructed in GPUP and can be referred to in all the draw operations
taking NativeImage. If the image data is used locally, the
data is synchronized from GPUP to WCP at that point.

Since RemoteNativeImageProxyClient is using WeakPtrs similar to existing
RenderingResourceObserver, convert RemoteResourceCacheProxy as a
heap allocated type that can be used with CheckedPtr. Fix the tech
debt in RenderingResourceObserver, and make it CheckedPtr type instead
of opting in for smart pointer rule exception.

This commit introduces a edge-case regression where a GPUP process
crash will lose the GPUP-side NativeImage data in case it was not
explicitly used in WCP before. Currently there are no call sites that
form long-term references. Later commits will introduce best-effort
synchronization where the long-term held NativeImage data is
sent from GPUP to WCP.

Not many call sites use NativeImages. ImageBitmap is one such case.
This speeds up PerformanceTests/Canvas/drawImageSourceImageBitmapCanvas2D.html
from 850ms to 650ms, but future commits will improve this substantially
more.

This is first commit in a series that will convert all image source
holders to use NativeImage, improving performance and resource use.
In future commits, NativeImage will be also made thread-safe, so that
instances references can be shared as well as passed freely across
threads.

* Source/WebCore/platform/graphics/Gradient.cpp:
(WebCore::Gradient::~Gradient):
* Source/WebCore/platform/graphics/NativeImage.cpp:
(WebCore::NativeImage::create):
(WebCore::NativeImage::createTransient):
(WebCore::NativeImage::NativeImage):
(WebCore::NativeImage::~NativeImage):
* Source/WebCore/platform/graphics/NativeImage.h:
* Source/WebCore/platform/graphics/RenderingResource.h:
* Source/WebCore/platform/graphics/cg/NativeImageCG.cpp:
(WebCore::NativeImage::create):
(WebCore::NativeImage::createTransient):
* Source/WebCore/platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::~DisplayList):
* Source/WebCore/platform/graphics/filters/FilterFunction.cpp:
(WebCore::FilterFunction::~FilterFunction):
* Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.cpp:
(WebKit::RemoteImageBuffer::copyNativeImage):
(WebKit::RemoteImageBuffer::getShareableBitmap): Deleted.
* Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h:
* Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.messages.in:
* Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::nativeImageBitmap):
(WebKit::RemoteRenderingBackend::cacheNativeImage):
* Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h:
* Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in:
* Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp:
(WebKit::RemoteResourceCache::cacheNativeImage):
* Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h:
* Source/WebKit/Sources.txt:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.cpp:
(WebKit::RemoteImageBufferProxy::send const):
(WebKit::RemoteImageBufferProxy::sendSync const):
(WebKit::RemoteImageBufferProxy::copyNativeImage const):
(WebKit::RemoteImageBufferProxy::send): Deleted.
(WebKit::RemoteImageBufferProxy::sendSync): Deleted.
* Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
* Source/WebKit/WebProcess/GPU/graphics/RemoteNativeImageProxy.cpp: Added.
(WebKit::placeholderPlatformImage):
(WebKit::RemoteNativeImageProxy::create):
(WebKit::RemoteNativeImageProxy::RemoteNativeImageProxy):
(WebKit::RemoteNativeImageProxy::~RemoteNativeImageProxy):
(WebKit::RemoteNativeImageProxy::platformImage const):
(WebKit::RemoteNativeImageProxy::size const):
(WebKit::RemoteNativeImageProxy::hasAlpha const):
(WebKit::RemoteNativeImageProxy::colorSpace const):
* Source/WebKit/WebProcess/GPU/graphics/RemoteNativeImageProxy.h: Added.
* Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::didClose):
(WebKit::RemoteRenderingBackendProxy::nativeImageCountForTesting const):
(WebKit::RemoteRenderingBackendProxy::createNativeImage):
(WebKit::RemoteRenderingBackendProxy::nativeImageBitmap):
(WebKit::RemoteRenderingBackendProxy::releaseMemory):
(WebKit::RemoteRenderingBackendProxy::releaseNativeImages):
(WebKit::RemoteRenderingBackendProxy::didPaintLayers):
(WebKit::RemoteRenderingBackendProxy::getShareableBitmap): Deleted.
* Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
(WebKit::RemoteRenderingBackendProxy::remoteResourceCacheProxy):
* Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp:
(WebKit::RemoteResourceCacheProxy::create):
(WebKit::RemoteResourceCacheProxy::createNativeImage):
(WebKit::RemoteResourceCacheProxy::willDestroyRemoteNativeImageProxy):
(WebKit::RemoteResourceCacheProxy::platformImage):
* Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h:

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to