Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a57ebb1d227dc33791da87d0fa7546a88053c98a
      
https://github.com/WebKit/WebKit/commit/a57ebb1d227dc33791da87d0fa7546a88053c98a
  Author: Sergio Villar Senin <[email protected]>
  Date:   2025-07-23 (Wed, 23 Jul 2025)

  Changed paths:
    M Source/WebCore/platform/xr/PlatformXR.h
    M Source/WebKit/Shared/XR/PlatformXR.serialization.in
    A Source/WebKit/Shared/XR/XRDeviceLayer.h
    M Source/WebKit/Shared/XR/XRDeviceProxy.cpp
    M Source/WebKit/Shared/XR/XRSystem.serialization.in
    M Source/WebKit/SourcesGTK.txt
    M Source/WebKit/SourcesWPE.txt
    M Source/WebKit/UIProcess/XR/PlatformXRCoordinator.h
    M Source/WebKit/UIProcess/XR/PlatformXRSystem.cpp
    M Source/WebKit/UIProcess/XR/PlatformXRSystem.h
    M Source/WebKit/UIProcess/XR/PlatformXRSystem.messages.in
    A Source/WebKit/UIProcess/XR/openxr/OpenXRLayer.cpp
    A Source/WebKit/UIProcess/XR/openxr/OpenXRLayer.h
    A Source/WebKit/UIProcess/XR/openxr/OpenXRSwapchain.cpp
    A Source/WebKit/UIProcess/XR/openxr/OpenXRSwapchain.h
    M Source/WebKit/UIProcess/XR/openxr/OpenXRUtils.h
    M Source/WebKit/UIProcess/XR/openxr/PlatformXROpenXR.cpp
    M Source/WebKit/UIProcess/XR/openxr/PlatformXROpenXR.h
    M Source/WebKit/UIProcess/XR/openxr/PlatformXRSystemOpenXR.cpp
    M Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.cpp
    M Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.h

  Log Message:
  -----------
  [WebXR][OpenXR] Fill in FrameData information
https://bugs.webkit.org/show_bug.cgi?id=295881

Reviewed by Carlos Garcia Campos.

XR information coming from XR devices is retrieved in the UI process
using OpenXR API. That info is then later transferred to the Web
Process to be consumed by the WebXR API. A struct called FrameData
is used to carry that information.

In this commit we're among other things collecting & sending:
- Views information: fov, pose
- Tracking information availability
- Floor location (transform from local space)
- Layer data (so far only 1 projection layer)

In the WebProcess the submitFrame() method receives a vector
of objects containing information about the layers. The WebXR
layers spec is still not available in WebKit but even without
that there is still at least one layer, the base layer.

That info was not passed to the UIProcess in submitFrame() because
it wasn't used by the ARKit implementation. However it's needed
for the OpenXR one because we get there the viewport information
that we need to create the stereo views (we use a single projection
layer that is split in as many parts as views we have, typically 2).

Serializing PlatformXR::Device::Layer proved to be really complex
as serializers do not deal well with having multiple nested namespaces
for a given type. That's why we had to "clone" that structure in
another one hanging directly from the WebKit namespace.

Also a new message had to be added as well to ask the UIProcess to
create the projection layer with the data coming from WebXR.

One of the most important pieces of information to send to the Web Process
is the texture were the WebGL rendering should happen to be later submitted
to the OpenXR compositor. This commit implements the required machinery
to acquire and release those textures coming from OpenXR. However that
cannot be directly used by WebGL, we need to eventually implement a similar
mechanism as the ExternalTexture used by Apple ports. That's why no
rendering is expected to actually happen in the texture provided by OpenXR.

Last but not least, when adding the swapchains code we detected 2 important
issues in the current implementation:
- OpenXR resources were not properly freed upon session exiting
- we were incorrectly running multiple sequences of xrBeginFrame->xrEndFrame
in parallel. The confusion arose from an incorrect interpretation of what
xrWaitFrame does. The current code assumed that xrWaitFrame would wait until the
previous xrEndFrame is finished. But that's wrong. As the specs say
"A subsequent xrWaitFrame call must block until the previous frame has been 
begun
with xrBeginFrame and must unblock independently of the corresponding call
to xrEndFrame". That's why we had to add some additional synchronization
using binary semaphores, basically identical to what ARKit implementation does.

* Source/WebCore/platform/xr/PlatformXR.h:
* Source/WebKit/Shared/XR/PlatformXR.serialization.in:
* Source/WebKit/Shared/XR/XRDeviceLayer.h: Copied from 
Source/WebKit/UIProcess/XR/openxr/PlatformXRSystemOpenXR.cpp.
* Source/WebKit/Shared/XR/XRDeviceProxy.cpp:
(WebKit::XRDeviceProxy::initializeTrackingAndRendering):
(WebKit::XRDeviceProxy::submitFrame):
* Source/WebKit/Shared/XR/XRSystem.serialization.in:
* Source/WebKit/SourcesGTK.txt:
* Source/WebKit/SourcesWPE.txt:
* Source/WebKit/UIProcess/XR/PlatformXRCoordinator.h:
* Source/WebKit/UIProcess/XR/PlatformXRSystem.cpp:
(WebKit::PlatformXRSystem::submitFrame):
* Source/WebKit/UIProcess/XR/PlatformXRSystem.h:
* Source/WebKit/UIProcess/XR/PlatformXRSystem.messages.in:
* Source/WebKit/UIProcess/XR/openxr/OpenXRLayer.cpp: Added.
(WebKit::OpenXRLayerProjection::create):
(WebKit::OpenXRLayerProjection::OpenXRLayerProjection):
(WebKit::OpenXRLayerProjection::startFrame):
(WebKit::OpenXRLayerProjection::endFrame):
* Source/WebKit/UIProcess/XR/openxr/OpenXRLayer.h: Added.
* Source/WebKit/UIProcess/XR/openxr/OpenXRSwapchain.cpp: Added.
(WebKit::OpenXRSwapchain::create):
(WebKit::OpenXRSwapchain::OpenXRSwapchain):
(WebKit::OpenXRSwapchain::~OpenXRSwapchain):
(WebKit::OpenXRSwapchain::acquireImage):
(WebKit::OpenXRSwapchain::releaseImage):
* Source/WebKit/UIProcess/XR/openxr/OpenXRSwapchain.h: Added.
(WebKit::OpenXRSwapchain::swapchain const):
(WebKit::OpenXRSwapchain::width const):
(WebKit::OpenXRSwapchain::height const):
(WebKit::OpenXRSwapchain::size const):
* Source/WebKit/UIProcess/XR/openxr/OpenXRUtils.h:
(WebKit::XrIdentityPose):
(WebKit::XrPosefToPose):
(WebKit::XrViewToView):
* Source/WebKit/UIProcess/XR/openxr/PlatformXROpenXR.cpp:
(WebKit::OpenXRCoordinator::~OpenXRCoordinator):
(WebKit::OpenXRCoordinator::getPrimaryDeviceInfo):
(WebKit::OpenXRCoordinator::createLayerProjection):
(WebKit::OpenXRCoordinator::endSessionIfExists):
(WebKit::OpenXRCoordinator::submitFrameInternal):
(WebKit::OpenXRCoordinator::submitFrame):
(WebKit::OpenXRCoordinator::collectViewConfigurations):
(WebKit::OpenXRCoordinator::initializeBlendModes):
(WebKit::OpenXRCoordinator::cleanupSessionAndAssociatedResources):
(WebKit::OpenXRCoordinator::handleSessionStateChange):
(WebKit::OpenXRCoordinator::populateFrameData):
(WebKit::OpenXRCoordinator::createReferenceSpacesIfNeeded):
(WebKit::OpenXRCoordinator::renderLoop):
(WebKit::OpenXRCoordinator::recommendedResolution const): Deleted.
* Source/WebKit/UIProcess/XR/openxr/PlatformXROpenXR.h:
* Source/WebKit/UIProcess/XR/openxr/PlatformXRSystemOpenXR.cpp:
(WebKit::PlatformXRSystem::createLayerProjection):
* Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.cpp:
(WebKit::PlatformXRSystemProxy::createLayerProjection):
(WebKit::PlatformXRSystemProxy::submitFrame):
* Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.h:

Canonical link: https://commits.webkit.org/297780@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to