← All reports

WebGPU distinct identifier type and map per object type

Component: WebGPU | 9c8b36b

LayoutTests/ipc/webgpu-bind-group-update-external-textures-open-encoder.html

entries: [{
binding: 0,
- bufferBinding: { buffer: boundTextureId, offset: 0, size: { } },
- identifier: boundTextureId,
- type: 4, // BindingResourceType::ExternalTexture
+ resource: { variantType: 'WebKit::WebGPUExternalTextureIdentifier', variant: boundTextureId },
}],

Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in

- [EnabledBy=WebGPUEnabled] void CreateGPU(WebKit::WebGPUIdentifier identifier, ...)
- [EnabledBy=WebGPUEnabled] void ReleaseGPU(WebKit::WebGPUIdentifier identifier)
+ [EnabledBy=WebGPUEnabled] void CreateGPU(WebKit::RemoteGPUIdentifier identifier, ...)
+ [EnabledBy=WebGPUEnabled] void ReleaseGPU(WebKit::RemoteGPUIdentifier identifier)

The WebContent process refers to GPU-side WebGPU objects by identifier over streaming IPC, and the GPU process resolves each identifier through WebGPU::ObjectHeap. Because WebContent is the untrusted sender, every identifier may be of the wrong type, stale, destroyed or never created. Previously all identifiers shared one type and one map of 16-byte Variants, and a type mismatch surfaced as a failed Variant conversion that yielded null.

The heap now keeps one map per object type, each keyed by its own identifier type; RemoteGPU gets RemoteGPUIdentifier. BindGroupEntry's bufferBinding/identifier/type triple collapses into a single resource Variant, and BindingResourceType is removed. Render-pass attachment views become a texture-view-or-texture Variant. RemoteGPU::IsValid keeps the untyped WebGPUIdentifier: an object exists if any per-type map contains the value, and it is valid if every object found is valid.

ObjectHeap memory drops 25-66% at 100 or more objects, and the redundant variant-to-type mapping after each lookup disappears. The change rewrites how the WebGPU trust boundary encodes and resolves object references.

Identifiers of different types may now share a value, so "one identifier, one object" no longer holds. Review every site that takes a raw value or the untyped WebGPUIdentifier, especially RemoteGPU::IsValid, for a wrong answer when a value is live in one map and destroyed or invalid in another. Re-check the new bind-group Variant deserialization and the WTF::switchOn conversion in WebGPUBindGroupEntry.cpp; the existing external-texture IPC tests in LayoutTests/ipc show these paths matter. The old attachment conversion tried texture view then texture with the same identifier, so the per-type replacement for views and resolve targets needs checking for missed or inconsistent handling. Destroy and release paths that touch more than one map should be checked for ordering and lifetime changes. Existing IPC fuzzers and PoCs that send raw identifiers will need rewriting against the new messages.