← All issues

WebXR Layers projection layer implementation

a965fc6

Source/WebCore/Modules/webxr/WebGLOpaqueTexture.cpp

+void WebGLOpaqueTexture::deleteObjectImpl(const AbstractLocker&, GraphicsContextGL*, PlatformGLObject)
+{
+ // Don't do anything as the context does not own the texture.
+}
+
+WebGLOpaqueTexture::~WebGLOpaqueTexture()
+{
+ if (!m_context)
+ return;
+ runDestructor();
+}

Source/WebCore/Modules/webxr/WebXRSession.cpp

-else if (session.m_activeRenderState->layers().size())
- session.m_activeRenderState->layers()[0]->startFrame(session.m_frameData);
+else if (session.m_activeRenderState->layers().size()) {
+ for (auto& layer : session.m_activeRenderState->layers())
+ layer->startFrame(session.m_frameData);
+}

WebXR Layers(XRWebGLBinding)는 web app이 framebuffer 대신 compositor가 관리하는 texture에 직접 렌더링할 수 있게 하는 extension입니다. XR headset에서 더 효율적인 compositing이 가능합니다.

이 commit은 WPE/GTK 포트에서 WebXR projection layer를 구현하며, 새로운 WebGLOpaqueTexture 클래스를 도입합니다. 이 클래스는 WebGLTexture의 서브클래스로, deleteObjectImpl이 의도적으로 no-op으로 구현되어 있습니다. GL texture의 수명이 GL context가 아닌 swapchain에 의해 관리되기 때문입니다.

아키텍처는 two-tier swapchain 구조를 사용합니다. color texture는 UIProcess의 XR compositor에서 cross-process로 공유되고(Linux에서는 DMABuf/GBM 사용), depth/stencil texture는 WebXRWebGLStaticImageSwapchain 항목으로 로컬에 할당됩니다.

UIProcess (XR Compositor / OpenXR)          WebProcess
│                                              │
├─ allocates color textures (DMABuf/GBM) ─────►│ WebXRWebGLSharedImageSwapchain
│   (shared image handles via IPC)             │   └─ WebGLOpaqueTexture (no ctx teardown)
│                                              │
│                                              ├─ allocates depth locally
│                                              │   WebXRWebGLStaticImageSwapchain
│                                              │   └─ WebGLOpaqueTexture
│                                              │
│                                              ├─ XRWebGLBinding::createProjectionLayer()
│                                              │   ├─ validate formats/dimensions
│                                              │   ├─ allocateColorTextures
│                                              │   ├─ allocateDepthTextures
│                                              │   └─ return XRProjectionLayer
│                                              │
│◄── device->submitFrame(frameLayers) ─────────┤ WebXRSession::onFrame

이는 상당한 규모의 새로운 attack surface입니다. XR compositor(UIProcess)와 렌더링 코드(WebProcess) 사이의 cross-process texture 공유 파이프라인과, GL context의 표준 소멸 경로를 의도적으로 우회하는 새로운 WebGL object 서브클래스가 함께 도입되었습니다.

commit은 spec 준수가 완전하지 않다고 명시하고 있습니다. 여러 파라미터가 무시되고 stereo left-right만 지원되는 상태입니다. 이런 구현 특성은 과거 사례에 비추어 볼 때, edge-case API 호출에서 validation이 누락될 가능성과 연결되는 경향이 있습니다.

WebGLOpaqueTexture의 ownership 모델은 GL texture 수명이 이를 사용하는 GL context와 분리된 구조입니다. swapchain이 backing GL object를 해제한 이후에도 script가 sub-image texture에 대한 JS reference를 유지하면, use-after-free가 발생할 가능성이 있습니다.

🔒

New cross-process texture sharing path and a WebGL object subclass with non-standard lifetime semantics — several audit directions included.

더 확인하려면 구독해 주세요