Always render DOM and WebGL in the GPU process on Cocoa platforms
Component: WebKit GPU Process | 12f9fee
Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp
Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp
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)
Significance
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.
Audit directions
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:
- The merged
RemoteImageBufferSetnow owns the GPU-side buffer swap and copy-forward logic (swapBuffersForDisplay,prepareBufferForDisplay), consuming web-process-supplied dirty regions and configuration. Check rect and size arithmetic, and whetherupdateConfigurationresetting front, back and secondary buffers leaves stale state such asm_previouslyPaintedRectorm_frontBufferIsCleared.computePaintingRects()moved intoPrepareBackingStoreBuffersData, which the web process now shares. - Any web-process proxy path that assumed
Acceleratedplus a provided backing store yields a buffer (createBackendForSerializedBuffer,createImageBufferinRemoteRenderingBackendProxy) must handle the new null return. CreateGraphicsContextGLand theRemoteGraphicsContextGLmessages are now gated only byWebGLEnabled; on Cocoa the GPU-side checks inGPUConnectionToWebProcess::createGraphicsContextGLare the lockdown-mode and draft-extensionsMESSAGE_CHECKs.- Proxy-side consumers of
GetVideoFrameBuffer, which now always passesfalseforcanSendIOSurface, and of the removed synchronousPixelBuffermessage, may carry stale assumptions about the video frame buffer format. RemoteLayerBackingStoreCollectionvolatility handling aftermarkInProcessBackingStoreVolatilewas removed is a place to look for use-after-purge or stale buffer-identifier bugs.allowsExitUnderMemoryPressurenow always returns false on Cocoa, so the GPU process stays resident under memory pressure, and leaks or memory exhaustion there become easier to reach.