Per-element transforms inside macOS Spatial Portals
Component: WebKit Model / Spatial Portals | f6c7f23
Source/WebKit/GPUProcess/graphics/Model/USDModel.swift
Spatial Portals (spatial: portal) render 3D <model> content in a separate space, and the WebContent process doesn't render it itself. WebModelPlayer and RemoteMeshProxy forward state to RemoteMesh in the GPU process, which hands it to MeshImpl/WebMesh and the Swift bridge in USDModel.swift that drives the USD renderer. Until now, only a global portal transform was applied.
RemoteMesh.update becomes UpdateModel and now carries a NodeIdentifier, and a new UpdatePortalChildTransform message pushes per-model transforms from WebContent to the GPU process. USDModel.swift gains meshNodes (mesh to node) and nodeTransforms (node to transform) maps. render composes the node's transform between the model transform and the original mesh transform, and WebModelPlayer::setEntityTransform is no longer a stub.
Significance
Models inside a portal can now be individually scaled, rotated and translated, with the transform applied in the GPU process. The change also widens the WebContent-to-GPU IPC interface for model rendering.
Audit directions
The GPU process now keeps per-node state, keyed on WebContent-supplied identifiers, that must stay consistent across update, transform, and remove. removeNode(_:) clears only nodeTransforms, while meshNodes entries are removed later in processRemovals. As a result, a mesh can still map to a removed node, and a later UpdatePortalChildTransform re-creates the entry that render then applies to the stale mapping. Unknown, stale, or reused NodeIdentifiers, messages arriving before UpdateModel, identifiers colliding across RemoteMesh instances, and repeated UpdateModel with a different node (updateMesh overwrites meshNodes[identifier]) are all worth testing. The kCSSPixelsPerMeter scaling in setPortalChildTransform happens on the sending side, so check RemoteMesh::updatePortalChildTransform for NaN, infinite, degenerate, or huge matrices from a sender that skips it. Also look at concurrent access to the Swift dictionaries during render(with:commandBuffer:). More broadly, the C++/Objective-C++/Swift bridge is a common place for lifetime and type-confusion bugs, and UpdateModel is now fire-and-forget where Update returned a reply.