← All reports

[WebXR] Plane detection support (new feature)

Component: WebCore WebXR | 730d282

LayoutTests/http/wpt/webxr/xrPlane_in_place_update.https.html

+ controller.updateWorld(floorWorld({ polygon: [{x: -2, z: -2}, {x: 2, z: -2}, {x: 2, z: 2}] }));
+ let frame = await nextFrame(session);
+ let second = onlyPlane(frame);
+ assert_true(frame.detectedPlanes.has(first), "the plane of the previous frame is still in the set");
+ assert_equals(second, first, "same XRPlane object");
+ assert_greater_than(first.lastChangedTime, firstTime, "lastChangedTime increased");
...
+ controller.updateWorld({ hitTestRegions: [] });
+ frame = await nextFrame(session);
+ assert_equals(frame.detectedPlanes.size, 0, "the plane is gone");
+ assert_equals(frame.getPose(retainedSpace, refSpace), null, "no pose for the plane space of a removed plane");

WebXR은 feature로 제어되는 모듈을 통해 immersive session에 실제 공간의 geometry 정보를 제공합니다. WebKit에서는 platform XR device가 UIProcess에서 동작합니다. WPE/GTK의 경우 OpenXR이 이 역할을 맡습니다. 이 device는 frame마다 데이터를 IPC로 WebContent에 전달하고, WebXRSession이 이를 DOM 객체로 변환합니다.

Plane Detection spec이 요구하는 조건은 다음과 같습니다. 먼저 XRPlane의 identity는 frame이 바뀌어도 동일하게 유지되어야 합니다. lastChangedTime은 polygon, orientation, label 중 하나가 바뀔 때만 갱신되어야 합니다. 또한 detectedPlanes는 animation frame이 활성 상태인 동안에만 유효합니다. 한편 plane이 제거되면 해당 plane의 planeSpace는 더 이상 resolve되지 않아야 합니다.

이번 commit에서 XRPlane, XRPlaneSet, XRPlaneOrientation, XRFrame.detectedPlanes, XRSession.initiateRoomCapture()가 추가되었습니다. 이 중 planeSpace는 내부 클래스인 WebXRPlaneSpace를 기반으로 구현되었습니다. UIProcess 쪽에는 OpenXRPlaneDetectionManager가 새로 추가되었습니다. 이 manager는 비동기 XrFuture handle을 이용해 OpenXR의 spatial-entity discovery 결과를 polling합니다. 이후 plane 기준 local 좌표를 WebXR의 좌표 규약에 맞게 변환합니다.

plane 데이터(pose, polygon, orientation, semantic label)는 PlatformXR.serialization.in에 추가되었습니다. 그 밖에 Quaternion helper가 리팩터링되었고, fake XR device에는 updateWorld와 detectedPlanes가 추가되었습니다.

단일 commit에 JS로 노출되는 API, UIProcess에서 WebContent로 향하는 새로운 IPC payload, 장시간 실행되는 async future를 다루는 native OpenXR backend가 함께 추가되었습니다. 게다가 XRPlane 객체는 frame이 바뀌어도 유지되면서 제자리에서 갱신됩니다. 결과적으로 platform layer와 DOM 사이에 새로운 lifetime 및 상태 동기화 요구사항이 생겨납니다.

Narrow: 먼저 WebXRSession::updateDetectedPlanes, invalidateDetectedPlanes, WebXRPlane::update/invalidate의 lifetime과 identity 처리를 살펴볼 필요가 있습니다. plane과 space를 frame 경계, session 종료, initiateRoomCapture promise 이후까지 유지시킨 뒤 stale session pointer가 남는지 확인해야 합니다. 또한 XRPlaneSet의 initializeSetLike backing이 갱신 과정에서 session의 plane map과 일관성을 유지하는지 점검해야 합니다. 재진입하는 forEach callback이 절반만 갱신된 set을 관찰하거나 수정할 수 없는지도 확인이 필요합니다. 새로 추가된 모든 accessor가 inactive frame 검사를 빠짐없이 적용하는지도 함께 살펴봐야 합니다.

Wider: PlatformXR.serialization.in의 deserialization 경로를 점검할 필요가 있습니다. vertex 개수, degenerate하거나 지나치게 큰 polygon, NaN/Inf pose, 중복 ID, 그리고 toDOMPolygon과 toXRPlaneOrientation에 들어오는 예상 밖의 enum 값이 주요 점검 대상입니다. 한편 OpenXRPlaneDetectionManager에서는 future polling 방식, pending 상태에서의 파괴, cleanupSessionAndAssociatedResources의 handle 정리 순서를 확인해야 합니다. 이 밖에 plane-detection descriptor에 대한 isFeaturePermitted/isFeatureSupported 처리도 살펴봐야 합니다. 삭제된 non-const Quaternion::accumulate를 사용하던 다른 호출 지점도 함께 확인할 필요가 있습니다.