WebGPU invalid objects created through the C++ API
Component: WebGPU | 73cab1d
Source/WebCore/Modules/WebGPU/GPUDevice.cpp
Source/WebCore/Modules/WebGPU/GPUBuffer.cpp
WebGPU in WebKit is layered. WebCore's GPUDevice wraps an abstract WebGPU::Device, which in the Web Process is a RemoteDeviceProxy that sends IPC to a RemoteDevice in the GPU Process. The RemoteDevice owns the real Metal-backed objects and tracks them by Web Process-chosen identifiers. The spec requires a failed create call to still return a usable but invalid JS object. Metal already had createInvalid() factories, but a C API layered over the proxies could not reach them.
This commit adds C++ API factories for invalid objects: Device::createInvalid{BindGroup, Buffer, CommandBuffer, Texture, ...}(), CommandEncoder::beginInvalid{Render,Compute}Pass(String&&), Texture::createInvalidView() and Device::generateAValidationError(String&&). Each proxy sends one new IPC message, and the GPU Process handles it like the matching create message using the invalid Metal object. Buffer::generateAValidationError() and its RemoteBuffer message are removed. GPUDevice builds its stand-in encoders from the new invalid factories instead of misusing a valid encoder, and no longer submits the stand-in command buffer.
Significance
A batch of new WebContent-to-GPU Process messages now creates objects from Web Process-supplied identifiers and error strings. Invalid objects also change shape: an invalid RemoteTextureProxy has zero size, mip level count and sample count, and an invalid RemoteQuerySetProxy has an optional type.
Audit directions
Check how the new handlers register identifiers, looking for duplicate or reused IDs and collisions with real objects of the same type. Probe whether invalid objects can flow into valid-object paths that assume a real backing: a zero-size texture, a query set with no type or count, an invalid command buffer in submit. Look for unchecked unwraps of the now-optional query-set type. The replacement encoder lifecycle (ordering of finish() versus the passes' end(), and the dropped submit) could leave state that differs from the old stand-ins. Also review the device-routed validation-error path, including the null-device case. The wide CAPI switch from metalFromAPI to fromAPI could leave type-confusion or lifetime gaps between Metal and proxy objects.