[webkit-changes] [WebKit/WebKit] 902a49: WebCore::IOSurface should not store a reference to...

Kimmo Kinnunen noreply at github.com
Wed Mar 15 11:04:08 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 902a49a99629ceb2bf363ee4c96b0f3fdd34afc3
      https://github.com/WebKit/WebKit/commit/902a49a99629ceb2bf363ee4c96b0f3fdd34afc3
  Author: Kimmo Kinnunen <kkinnunen at apple.com>
  Date:   2023-03-15 (Wed, 15 Mar 2023)

  Changed paths:
    M Source/WebCore/Modules/system-preview/ARKitBadgeSystemImage.mm
    M Source/WebCore/platform/graphics/ImageBuffer.h
    M Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp
    M Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp
    M Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h
    M Source/WebCore/platform/graphics/cocoa/IOSurface.h
    M Source/WebCore/platform/graphics/cocoa/IOSurface.mm
    M Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.cpp
    M Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h
    M Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
    M Source/WebKit/UIProcess/Automation/cocoa/WebAutomationSessionCocoa.mm
    M Source/WebKit/UIProcess/mac/ViewSnapshotStoreMac.mm
    M Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h
    M Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp
    M Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.h
    M Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/WebCore/cocoa/IOSurfaceTests.mm

  Log Message:
  -----------
  WebCore::IOSurface should not store a reference to a CGContext
https://bugs.webkit.org/show_bug.cgi?id=253698
rdar://106547690

Reviewed by Matt Woodrow.

An IOSurface might be written to and read from by multiple CGContexts
or even other contexts such as Metal (via WebGL / ANGLE).

An arbitrary context that has been used is not useful anymore in the
future, as the caller will not know the context state.

Due to these points, does not make sense to store a CGContext as a member in
WebCore::IOSurface.

The only real CG draw to an IOSurface happens via ImageBufferIOSurfaceBackend.
Store the context there, as that is the place to use the context.

Caching the context behind the interface creates source of bugs, as in
here fixed WebAutomationSession / ViewSnapshot where the callers
would inadvertedly create the contexts and leave them stored.

Remove invalid comment about CGIOSurfaceContextCreate affecting the
use count. The added test proves otherwise.

* Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::willAddSurface):
* Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
(WebCore::ImageBufferIOSurfaceBackend::create):
(WebCore::ImageBufferIOSurfaceBackend::ImageBufferIOSurfaceBackend):
(WebCore::ImageBufferIOSurfaceBackend::~ImageBufferIOSurfaceBackend):
(WebCore::ImageBufferIOSurfaceBackend::context):
(WebCore::ImageBufferIOSurfaceBackend::ensurePlatformContext):
(WebCore::ImageBufferIOSurfaceBackend::copyNativeImage):
(WebCore::ImageBufferIOSurfaceBackend::copyNativeImageForDrawing):
(WebCore::ImageBufferIOSurfaceBackend::sinkIntoNativeImage):
(WebCore::ImageBufferIOSurfaceBackend::releaseGraphicsContext):
* Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
* Source/WebCore/platform/graphics/cocoa/IOSurface.h:
* Source/WebCore/platform/graphics/cocoa/IOSurface.mm:
(WebCore::IOSurface::create):
(WebCore::IOSurface::createFromImage):
(WebCore::IOSurface::createImage):
(WebCore::IOSurface::sinkIntoImage):
(WebCore::IOSurface::createPlatformContext):
(WebCore::IOSurface::setOwnershipIdentity):
(WebCore::IOSurface::ensurePlatformContext): Deleted.
(WebCore::IOSurface::releasePlatformContext): Deleted.
* Source/WebKit/UIProcess/Automation/cocoa/WebAutomationSessionCocoa.mm:
(WebKit::WebAutomationSession::platformGetBase64EncodedPNGData):
* Source/WebKit/UIProcess/mac/ViewSnapshotStoreMac.mm:
(WebKit::ViewSnapshot::setVolatile):
(WebKit::ViewSnapshot::asImageForTesting):
* Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp:
(WebKit::ImageBufferShareableMappedIOSurfaceBackend::create):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:

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




More information about the webkit-changes mailing list