WebGPU: Make WebCore and WebKit use WebGPU C++ API
Component: WebGPU | b6ab04a
Source/WebCore/Modules/WebGPU/GPUAdapter.cpp
WebGPU in WebKit is split across processes: the Web Process runs the JS bindings (GPUDevice, GPUBuffer, …), which talk to proxies that serialize calls over IPC to the GPU Process, where RemoteX objects hold the Metal-backed implementation. Handles crossing IPC resolve through an object heap and descriptors convert field by field, so type definitions and converters define what the GPU Process accepts from an untrusted renderer.
WebCore and WebKit now use the WebGPU C++ API (WebGPU::X, from WebGPU/WebGPUCpp.h) as the only interface to the implementations and no longer touch any wgpu* function or WGPU* type. WebCore::GPUX holds a Ref<WebGPU::X>, RemoteXProxy implements WebGPU::X in the Web Process, and RemoteX wraps WebGPU::Metal::X. The XImpl classes, isRemoteXProxy()/isXImpl() checks, C API conversion helpers and InternalAPI directory are gone, and IPC converters target the API types.
Before:
WebCore (JS binding) └─► WebCore::WebGPU::X (abstract)
├─► XImpl ──► ConvertToBackingContext ──► wgpu*/WGPU* C API
└─► RemoteXProxy ──IPC──► RemoteX ──► WebGPU::XImpl ──► WGPU* C API
After:
WebCore::GPUX { Ref<WebGPU::X>, label } └─► WebGPU::X (WebGPUCpp.h)
├─► WebGPU::Metal::X (in-process)
└─► RemoteXProxy ──IPC (API structs)──► RemoteX { WebGPU::Metal::X as WebGPU::X }
Significance
This rewrites the WebContent-to-GPU-process WebGPU object model and its IPC serialization in one change. Unknown GPUBufferUsage bits, previously dropped from bit 16 up, now map to an Invalid sentinel that fails validation. Color write masks wider than the four channel bits likewise become WebGPU::ColorWrite::Invalid.
Audit directions
- Borrowed spans across async boundaries. Descriptors now borrow their arrays as spans; look for dangling spans in asynchronous paths such as pipeline creation and in IPC decode-to-descriptor paths.
- Serializer parity. Descriptors without object handles now travel as raw API structs; check that
WebGPU.serialization.invalidates enums, flags and array sizes as before, and that the newInvalidsentinels are handled everywhere they can reach in the GPU Process. - Lost type guards. With
isRemoteXProxy()/isXImpl()and the downcast helpers gone, check what replaces those type-confusion guards and whetherRemoteXtrusts aWebGPU::Xthat could be the wrong concrete type. - Canvas presentation lifetime.
unconfigure()now reaches the presentation context and size travels viaCanvasConfiguration; review render-buffer recreation, resize and teardown ordering, and XR layer backing lifetime. - ARC/non-ARC boundary. Raw CF references and spans replace
RetainPtrat the new boundary — a classic place for leaks or over-releases. Labels now stored in WebCore are a minor secondary point.