← All reports

Always render DOM and WebGL in the GPU process on Cocoa platforms

Component: WebKit GPU Process | 12f9fee

Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp

switch (renderingMode) {
- case RenderingMode::Accelerated:
-#if HAVE(IOSURFACE)
- if (auto backend = ImageBufferShareableMappedIOSurfaceBackend::create(parameters, WTF::move(*providedBackingStore), creationContext.useIOSurfaceWebKitBehavior))
- return ImageBuffer::create(parameters, creationContext, WTF::move(backend));
-#endif
- return nullptr;
case RenderingMode::Unaccelerated:
...
+ case RenderingMode::Accelerated:
case RenderingMode::PDFDocument:
case RenderingMode::DisplayList:
- // These have no backing store to hand over.
+ // These have no backing store the web process can hand over.
return nullptr;

Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp

MESSAGE_CHECK(!isLockdownModeEnabled());
+#if !PLATFORM(COCOA)
+ MESSAGE_CHECK(m_sharedPreferencesForWebProcess.useGPUProcessForWebGLEnabled);
+#endif

WebKit can paint DOM content either in the web process, using an in-process IOSurface-backed backing store, or by sending display lists to the GPU process through RemoteRenderingBackend and RemoteImageBufferSet. WebGL has the same split, with RemoteGraphicsContextGL in the GPU process driven over a stream IPC connection. On Cocoa the web content sandbox already requires the GPU process for both, so the preference-selected in-process paths could no longer work.

This commit compiles out UseGPUProcessForDOMRenderingEnabled and UseGPUProcessForWebGLEnabled on Cocoa, along with the ENABLE_GPU_PROCESS_DOM_RENDERING_BY_DEFAULT and ENABLE_GPU_PROCESS_WEBGL_BY_DEFAULT macros. RemoteLayerWithInProcessRenderingBackingStore and RemoteLayerWithRemoteRenderingBackingStore fold into RemoteLayerBackingStore, and ImageBufferSet merges into RemoteImageBufferSet. The RemoteVideoFrameObjectHeap::PixelBuffer message, the canSendIOSurface argument of GetVideoFrameBuffer, ImageBuffer::backendGeneration() and BufferAndBackendInfo::fromImageBuffer() are deleted. In allocateImageBuffer, Accelerated with a provided backing store now returns nullptr instead of wrapping an IOSurface.

Before (Cocoa):                          After (Cocoa):
WebContent                               WebContent
 ├─ pref: DOM/WebGL in GPUP?              ├─ DOM: display lists
 │   ├─ no: in-process BackingStore       └─ WebGL: GL stream
 │   │     (IOSurface alloc in WCP)              │ IPC
 │   └─ yes: RemoteBackingStore                  ▼
 │          └─► GPUP                       GPU Process
 │ IPC                                      ├─ RemoteRenderingBackend
 ▼                                          │    (Accelerated + provided
GPU Process                                 │     backing store => nullptr)
 ├─ allocateImageBuffer accepts              ├─ RemoteImageBufferSet (merged)
 │   IOSurface-backed store                  └─ RemoteGraphicsContextGL
 └─ RemoteVideoFrameObjectHeap::PixelBuffer  (PixelBuffer msg removed)

The in-process paths were effectively dead code on Cocoa, so deleting them leaves the remote path as the only implementation. On Cocoa, the GPU process's validation of web-process-supplied parameters is now the only rendering trust boundary left. The GPU process no longer accepts IOSurface-backed buffers from the web process, and the web process no longer allocates IOSurfaces for remote image buffers.

Large cross-process refactors of rendering code tend to leave stale assumptions on whichever side was not the focus. The places this one concentrates risk: