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

Bypassing Enter AR / Enter VR button by default #224

Closed
TiborUdvari opened this issue Sep 6, 2024 · 4 comments
Closed

Bypassing Enter AR / Enter VR button by default #224

TiborUdvari opened this issue Sep 6, 2024 · 4 comments
Assignees

Comments

@TiborUdvari
Copy link
Collaborator

Feature enhancement details:

While developing, repeatedly pressing the Enter AR button can be tedious. Transitioning from inline to immersive sessions can help with this in the case of VR, but it's not the ideal solution.

Once a user has granted permission on a webpage, they ideally shouldn't be asked for it again. However, due to security concerns, this is currently not possible. The WebXR navigation proposal is expected to address this in the future, with the meta quest browser being the only current implementation. It would be ideal to have a solution that works while coding on a computer.

A potential initial implementation that could be more useful is for web editors like the p5 web editor or P5LIVE, leveraging the use of iframes. Theoretically, it might be possible to request an immersive session on the parent window of the sketch and recreate the rendering context with the parent window still running the immersive session.

More details here:
immersive-web/navigation#17
ffd8/P5LIVE#95

@TiborUdvari TiborUdvari self-assigned this Sep 6, 2024
@TiborUdvari
Copy link
Collaborator Author

After a lot of fumbling around, I found when using the Immersive Web Emulator, the UA doesn't actually check if the requestSession is called from the user action, so easiest way for this use case is to check if the emulator is active and directly launch the experience.

@TiborUdvari
Copy link
Collaborator Author

A test I made was trying to persist the XRSession on the parent frame and reuse on subsequent calls, however the WebXR Polyfill has a lot of checks to see if the instance is actually an XRSession. On a new iframe run the polyfill is run again and the prototype is not the same, so it fails on these sort of tests. I tried messing around with the prototype chains to fool it to work, but there would probably be a lot of unintended consequences.

if (!(session instanceof XRSession)) {

https://github.com/immersive-web/webxr-polyfill/blob/7a6090614e226e2d2839f251a451f559bb2358fc/src/api/XRWebGLLayer.js#L43

I believe that the parent.frame XR Session persistance should work on real devices though, but still need to validate the approach.

@TiborUdvari TiborUdvari changed the title Bypassing Enter AR / Enter VR button for development Bypassing Enter AR / Enter VR button by default Sep 14, 2024
@TiborUdvari
Copy link
Collaborator Author

OK, so I've been thinking a lot about this, and IMO the default behavior should be attempting to start a session without a user action directly.

  • If people are using the Immersive Web Editor in the p5 web editor, for instance, they would be presented directly with the sketch's result instead of pressing the play button followed by the enter XR button.
  • If they want to try it out on a device, this initial call would fail, and the behavior would be as is.

This accounts for most use cases. A flag would need to deactivate this in case somebody wants to see the normal user flow.

I found a flag on the Meta Quest Browser to deactivate the need for a user action to launch the experience, meaning that after a hard reload, a new immersive session should be started immediately. However, this might not be fluid, and maybe hosting the session on the parent iframe would also be necessary, but this would be a second step.

@TiborUdvari
Copy link
Collaborator Author

This was done and documented in 47695b8

Hopefully it's easier to develop now.

I left the default behaviour with createARCanvas, createVRCanvas, so that older sketches still work the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant