Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebXR] Add state checking to WebXR IPC calls #23536

Conversation

achan00
Copy link
Contributor

@achan00 achan00 commented Jan 30, 2024

bd55010

[WebXR] Add state checking to WebXR IPC calls
https://bugs.webkit.org/show_bug.cgi?id=268404
rdar://121553978

Reviewed by Dan Glastonbury.

Track internal state in PlatformXRSystem and check that we are
in the expected state when the IPC call is made.

Remove unnecessary parameters in PlatformXRSystem::initializeTrackingAndRendering()
as that information can be cached in this class and there's no
need to pass that info over again.

* Source/WebCore/Modules/webxr/WebXRSystem.cpp:
(WebCore::WebXRSystem::resolveFeaturePermissions const):
We should not call into platform code for requesting permissions
for simulated test devices.
* Source/WebKit/Shared/XR/XRDeviceProxy.cpp:
(WebKit::XRDeviceProxy::initializeTrackingAndRendering):
* Source/WebKit/UIProcess/XR/PlatformXRSystem.cpp:
(WebKit::PlatformXRSystem::invalidate):
(WebKit::PlatformXRSystem::ensureImmersiveSessionActivity):
(WebKit::checkFeaturesConsent):
Helper function to check whether all the features in the first
argument are included in the second list of granted features.
(WebKit::PlatformXRSystem::requestPermissionOnSessionFeatures):
For immersive modes, check that we are in the idle state before
requesting permissions via the PlatformXRCoordinator.
When we get the granted permissions back, check whether all the
required features have been granted permission. Update the
immersive session state accordingly based on whether the
session can start.
(WebKit::PlatformXRSystem::initializeTrackingAndRendering):
Remove the parameters and use the cached immersive session
mode and granted features instead.
(WebKit::PlatformXRSystem::shutDownTrackingAndRendering):
(WebKit::PlatformXRSystem::requestFrame):
(WebKit::PlatformXRSystem::submitFrame):
(WebKit::PlatformXRSystem::sessionDidEnd):
(WebKit::PlatformXRSystem::setImmersiveSessionState):
(WebKit::PlatformXRSystem::invalidateImmersiveSessionState):
* Source/WebKit/UIProcess/XR/PlatformXRSystem.h:
* Source/WebKit/UIProcess/XR/PlatformXRSystem.messages.in:
* Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.cpp:
(WebKit::PlatformXRSystemProxy::initializeTrackingAndRendering):
* Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.h:

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

f43336e

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe   πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac   πŸ§ͺ api-wpe
  πŸ§ͺ ios-wk2-wpt   πŸ§ͺ mac-wk1 βœ… πŸ›  gtk
βœ… πŸ§ͺ api-ios   πŸ§ͺ mac-wk2   πŸ§ͺ gtk-wk2
βœ… πŸ›  tv   πŸ§ͺ mac-AS-debug-wk2   πŸ§ͺ api-gtk
  πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge   πŸ›  watch
  πŸ›  watch-sim

@achan00 achan00 requested a review from cdumez as a code owner January 30, 2024 22:01
@achan00 achan00 self-assigned this Jan 30, 2024
@achan00 achan00 added the WebXR For bugs in WebXR label Jan 30, 2024
@achan00 achan00 requested a review from djg January 30, 2024 22:02
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jan 30, 2024
@achan00 achan00 removed the merging-blocked Applied to prevent a change from being merged label Jan 31, 2024
@achan00 achan00 force-pushed the eng/WebXR-Add-state-checking-to-WebXR-IPC-calls branch from 2ff5f4f to 1e5485d Compare January 31, 2024 06:06
@webkit-early-warning-system
Copy link
Collaborator

Starting EWS tests for 1e5485d. Live statuses available at the PR page, #23536

@achan00 achan00 force-pushed the eng/WebXR-Add-state-checking-to-WebXR-IPC-calls branch from 1e5485d to c61ea0a Compare January 31, 2024 07:13
Copy link
Contributor

@djg djg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

I'm happy to accept this now, but in a future patch, I'd like to refactor the state management to use std::variant for each state to eliminate the need to check for valid data keep in std::optional.

This could be done in an effort to unify the WebXR ARKit system with Compositor.

@@ -146,6 +211,22 @@ void PlatformXRSystem::sessionDidUpdateVisibilityState(XRDeviceIdentifier device
});
}

void PlatformXRSystem::setImmersiveSessionState(ImmersiveSessionState state)
{
RELEASE_LOG_DEBUG(XR, "PlatformXRSystem: Immersive state update: Old=%d, New=%d", (int)m_immersiveSessionState, (int)state);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to ship with this logging? (Dean always asked me this question)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it.

@achan00 achan00 force-pushed the eng/WebXR-Add-state-checking-to-WebXR-IPC-calls branch from c61ea0a to f43336e Compare February 1, 2024 00:54
@achan00 achan00 added the merge-queue Applied to send a pull request to merge-queue label Feb 1, 2024
https://bugs.webkit.org/show_bug.cgi?id=268404
rdar://121553978

Reviewed by Dan Glastonbury.

Track internal state in PlatformXRSystem and check that we are
in the expected state when the IPC call is made.

Remove unnecessary parameters in PlatformXRSystem::initializeTrackingAndRendering()
as that information can be cached in this class and there's no
need to pass that info over again.

* Source/WebCore/Modules/webxr/WebXRSystem.cpp:
(WebCore::WebXRSystem::resolveFeaturePermissions const):
We should not call into platform code for requesting permissions
for simulated test devices.
* Source/WebKit/Shared/XR/XRDeviceProxy.cpp:
(WebKit::XRDeviceProxy::initializeTrackingAndRendering):
* Source/WebKit/UIProcess/XR/PlatformXRSystem.cpp:
(WebKit::PlatformXRSystem::invalidate):
(WebKit::PlatformXRSystem::ensureImmersiveSessionActivity):
(WebKit::checkFeaturesConsent):
Helper function to check whether all the features in the first
argument are included in the second list of granted features.
(WebKit::PlatformXRSystem::requestPermissionOnSessionFeatures):
For immersive modes, check that we are in the idle state before
requesting permissions via the PlatformXRCoordinator.
When we get the granted permissions back, check whether all the
required features have been granted permission. Update the
immersive session state accordingly based on whether the
session can start.
(WebKit::PlatformXRSystem::initializeTrackingAndRendering):
Remove the parameters and use the cached immersive session
mode and granted features instead.
(WebKit::PlatformXRSystem::shutDownTrackingAndRendering):
(WebKit::PlatformXRSystem::requestFrame):
(WebKit::PlatformXRSystem::submitFrame):
(WebKit::PlatformXRSystem::sessionDidEnd):
(WebKit::PlatformXRSystem::setImmersiveSessionState):
(WebKit::PlatformXRSystem::invalidateImmersiveSessionState):
* Source/WebKit/UIProcess/XR/PlatformXRSystem.h:
* Source/WebKit/UIProcess/XR/PlatformXRSystem.messages.in:
* Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.cpp:
(WebKit::PlatformXRSystemProxy::initializeTrackingAndRendering):
* Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.h:

Canonical link: https://commits.webkit.org/273875@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/WebXR-Add-state-checking-to-WebXR-IPC-calls branch from f43336e to bd55010 Compare February 1, 2024 02:10
@webkit-commit-queue
Copy link
Collaborator

Committed 273875@main (bd55010): https://commits.webkit.org/273875@main

Reviewed commits have been landed. Closing PR #23536 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit bd55010 into WebKit:main Feb 1, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebXR For bugs in WebXR
Projects
None yet
5 participants