← All reports

Anchoring promoted portal children to a `<model>` on visionOS

Component: WebCore Model Element | 42cec75

Source/WebCore/Modules/model-element/SpatialPortalController.cpp

+ auto& state = m_promotedChildAnchors.add(rootNodeID, PromotedChildAnchor { }).iterator->value;
+ auto anchor = resolvedAnchor(*element, renderer->style(), anchorsByName, state.anchorWarningIssued);
+ if (state.anchorNode == anchor.node && state.anchorPlacement == anchor.placement)
+ continue;
+
+ state.anchorNode = anchor.node;
+ state.anchorPlacement = WTF::move(anchor.placement);
+ player->setPromotedChildAnchor(rootNodeID, state.anchorNode, state.anchorPlacement);

Source/WebCore/rendering/RenderLayer.cpp

+ if (auto anchoredProjection = element ? controller->anchoredPromotedChildProjection(element->nodeIdentifier()) : std::nullopt) {
+ projection.multiply(*anchoredProjection);
+ ...
+ } else
+ projection.multiply(controller->hostedContentProjection());

A spatial portal (spatial: portal) hosts 3D content. Its <model> elements are rendered out of process by the Model process through ModelProcessModelPlayerProxy, which owns a RealityKit-style scene graph. Promoted children are ordinary DOM elements whose layers are hoisted into that scene graph under a hosted-layer container. WebContent's SpatialPortalController resolves each child's layout and anchor state and pushes it over the ModelPlayer IPC.

This commit lets a promoted child anchor to a <model> in the same portal, or to a named entity inside it, using position-anchor plus position-context: anchor. position-anchor alone remains ordinary CSS anchor positioning. WebContent resolves the CSS anchor name, plus an optional #placement suffix naming an entity, into a NodeIdentifier and a placement string, and sends them via the new setPromotedChildAnchor message. The Model process re-parents the child's entity under the anchor (falling back to the host root if the placement is unknown). It reports transforms back through didUpdateAnchoredPortalChildTransforms, and RenderLayer::hostedPortalContentProjection uses them for hit testing. The child follows its anchor but is not scaled by it. A sublayer reset in setPortalHostedLayers/updatePortalSceneLayerHierarchy detaches the child, and updateAnchorParenting re-attaches it.

Page-controlled anchor names and layout timing now drive scene-graph parenting in the Model process, and computed transforms flow back into WebContent hit testing. That makes this a new bidirectional cross-process surface for the spatial-portal pipeline.

A compromised WebContent can send arbitrary values for all three setPromotedChildAnchor fields: the child root NodeIdentifier, the optional anchor NodeIdentifier, and the placement string. The validation therefore lives on the receiving side, in ModelProcessModelPlayerProxy.mm, and has to be read in the full patch. Check whether each identifier is validated, and whether a forged message can reference a player, child or entity that is gone or belongs to another portal or page.

Ordering around updatePortalChildAnchoring, updatePortalSceneLayerHierarchy and setPortalHostedLayers deserves attention because sublayer resets detach anchored children. Any path that skips the re-attach could leave stale or dangling entity references.

Other areas to probe: