[webkit-changes] [WebKit/WebKit] db0a32: WebGL creating long dependencies in backboard rend...

Kimmo Kinnunen noreply at github.com
Wed Apr 26 12:32:49 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: db0a320e698a2411f40ab61f51e5dcd9f07bc8bf
      https://github.com/WebKit/WebKit/commit/db0a320e698a2411f40ab61f51e5dcd9f07bc8bf
  Author: Kimmo Kinnunen <kkinnunen at apple.com>
  Date:   2023-04-26 (Wed, 26 Apr 2023)

  Changed paths:
    M Source/WebCore/platform/graphics/GraphicsContextGL.h
    M Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp
    M Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h
    M Source/WebCore/platform/graphics/ca/PlatformCALayer.h
    M Source/WebCore/platform/graphics/ca/PlatformCALayer.mm
    M Source/WebCore/platform/graphics/ca/PlatformCALayerDelegatedContents.h
    M Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h
    M Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
    M Source/WebCore/platform/graphics/cocoa/ANGLEUtilitiesCocoa.h
    M Source/WebCore/platform/graphics/cocoa/ANGLEUtilitiesCocoa.mm
    M Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h
    M Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm
    M Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm
    M Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h
    M Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in
    M Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp
    M Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h
    M Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm
    M Source/WebKit/WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm
    M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h
    M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.mm
    M Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm

  Log Message:
  -----------
  WebGL creating long dependencies in backboard render times
https://bugs.webkit.org/show_bug.cgi?id=254912
rdar://106957008

Reviewed by Simon Fraser.

Before, WebGL would wait for 3rd oldest frame to finish before
continuing to create a new frame. In case the frames were very slow,
they would slow the whole system down as the system compositor
would wait for each submitted frame to finish.

Instead, wait at the WebKit level for the WebGL frames to finish
rendering before submitting the frames to the system compositor.

Wait WebGL rendering to IOSurfaces to finish before setting the surface
as the "delegated contents" of the PlatformCALayer.

Original plan was to wait for the MTLSharedEvent associated with the
context. This is not useful, as waiting has to happen in WP and using
MTLSharedEvent in WP is not possible in full GPUP mode. Instead,
encapsulate the wait fence functionality in new interface
PlatformCALayerDelegatedContentsFence.

The feature has client configurations:
 1. WP-side compositing, WP-side WebGL
 2. WP-side compositing, GPUP-side WebGL
 3. UI-side compositing, GPUP-side WebGL

WP-side compositing:
Background: delegated contents is being set during [CALayer display].

The fence is waited on during the [CALayer display]
when the delegated contents is being set to the PlatformCALayer. This
happens on the main thread.

UI-side compositing:
Background: delegated contents is being set during
RemoteLayerTreeContext::buildTransaction, prepareBackingStoresForDisplay
phase.

When setting the delegated contents, add the fence to the list
of "front buffer flushers". The fence is wrapped inside a wrapper that
implements the flusher interface.

Waiting happens on the flusher dispatch queue.

WP-side WebGL
Background: During WebPage rendering update, the WebGL context layers
will be "prepared for display".

As a last ANGLE OpenGL command for the frame, this will insert the EGL
fence that will signal the finishing of the frame. The inserted fence
(ANGLE EGL sync object) encapsulates a MTLSharedEvent signal. Upon
completion of the event signal, Metal will invoke the
MTLSharedEventListener with the pre-set block for the signal value, in
the Metal owned background thread. The block will notify the delegated
contents fence Condition.

GPUP-side WebGL
During prepare for display, send IPC::Semaphore to the GPUP side.
This semaphore will be waited on by the implementation of
PlatformCALayerDelegatedContentsFence.

In GPUP side, insert the semaphore signal into the EGL fence signal,
similar to above.
IPC::Semaphore is used to trampoline the notification, because
WP cannot use MTLSharedEvent directly due to IOKit blocking. IPC
message waits cannot be used because they would spin the message
processing, the IPC connection does not exist at the compositor level,
OffscreenCanvas would have different connection thread, and flusher
dispatch queue doesn't have the IPC connection.

* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::waitAndUpdateOldestFrame): Deleted.
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h:
* Source/WebCore/platform/graphics/ca/PlatformCALayer.h:
* Source/WebCore/platform/graphics/ca/PlatformCALayer.mm:
(WebCore::PlatformCALayer::setDelegatedContents):
(WebCore::PlatformCALayer::setDelegatedContentsFinishedEvent): Deleted.
* Source/WebCore/platform/graphics/ca/PlatformCALayerDelegatedContents.h:
* Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
* Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(WebCore::PlatformCALayerCocoa::setDelegatedContents):
(WebCore::PlatformCALayerCocoa::setDelegatedContentsFinishedEvent): Deleted.
* Source/WebCore/platform/graphics/cocoa/ANGLEUtilitiesCocoa.h:
* Source/WebCore/platform/graphics/cocoa/ANGLEUtilitiesCocoa.mm:
(WebCore::newSharedEventWithMachPort):
(WebCore::newSharedEvent):
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h:
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
(WebCore::GraphicsContextGLCocoa::MetalFenceSharedState::event):
(WebCore::GraphicsContextGLCocoa::MetalFenceSharedState::listener):
(WebCore::GraphicsContextGLCocoa::MetalFenceSharedState::MetalFenceSharedState):
(WebCore::GraphicsContextGLCocoa::platformInitialize):
(WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
(WebCore::GraphicsContextGLCocoa::createSyncWithSharedEvent):
(WebCore::GraphicsContextGLCocoa::clientWaitSyncWithFlush):
(WebCore::GraphicsContextGLCocoa::prepareForDisplay):
(WebCore::GraphicsContextGLCocoa::prepareForDisplayWithFinishedSignal):
(WebCore::GraphicsContextGLCocoa::insertCommandsCompleteSignalOrInvoke):
(WebCore::GraphicsContextGLCocoa::metalFenceSharedState):
(WebCore::GraphicsContextGLCocoa::MetalFenceSharedState::create):
* Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm:
(): Deleted.
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h:
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp:
(WebKit::RemoteGraphicsContextGLCocoa::prepareForDisplay):
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::setDelegatedContents):
(WebKit::RemoteLayerBackingStore::setDelegatedContentsFinishedEvent): Deleted.
* Source/WebKit/WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.mm:
(WebKit::PlatformCALayerRemote::setDelegatedContentsFinishedEvent): Deleted.

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




More information about the webkit-changes mailing list