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

makeXRCompatible call causes WebGL ContextLost error in a PCVR setup with Meta Quest Link #30674

Open
tjsc0 opened this issue Mar 7, 2025 · 3 comments
Labels

Comments

@tjsc0
Copy link

tjsc0 commented Mar 7, 2025

Description

I know these kind of issues are normally closed with the Device Issue label, but please bear with me, I think I've made some new discoveries.

I was able to reproduce the issue outlined in #30505 on a different headset (Meta Quest 3) in a PCVR setup (PC Virtual Reality, rendering on PC then output to a headset with wired or wireless connection). All of the XR examples from Three.js fail to render with the following console errors:

WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
THREE.WebGLRenderer: Context Lost.
Uncaught (in promise) InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.Understand this errorAI
THREE.WebGLRenderer: Context Restored.

while the official WebXR samples work perfectly fine. The key difference between Three.js and WebXR Samples is that the WebGL rendering context is created with xrCompatible: true initially in the WebXR Samples while Three.js calls the asynchronous makeXRCompatible method before entering an XR session. I confirmed the Three.js VR examples worked after adding xrCompatible: true to https://github.com/mrdoob/three.js/blob/dev/src/renderers/WebGLRenderer.js#L353

I know the latter is the recommended approach according to spec (related to #19275), but is it possible that we're not correctly handling the lost/restored context associated with the makeXRCompatible call in Three.js? Since this is broken on both Meta Quest Link and HTC Vive with SteamVR, and the WebXR Samples work fine for both setup.

It's also possible that this is a Meta Quest Link runtime issue, so I also filed meta-quest/webxr-first-steps-react#2

Reproduction steps

  1. set up Meta Quest Link on a Windows PC: https://www.meta.com/help/quest/1517439565442928/
  2. validate WebXR works through Meta Quest Link with the official WebXR samples: https://immersive-web.github.io/webxr-samples/
  3. load Three.js' WebXR examples and click Enter VR: https://threejs.org/examples/?q=roller#webxr_vr_rollercoaster

Code

WebGLRenderingContext.makeXRCompatible()
// vs
canvas.getContext({ xrCompatible: true })

Live example

Screenshots

oculus mirror

Version

r174

Device

Headset

Browser

Chrome

OS

Windows

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 7, 2025

@cabanier Can you give us a advice here? Is three.js using makeXRCompatible() correctly?

if ( attributes.xrCompatible !== true ) {
await gl.makeXRCompatible();
}

@Mugen87 Mugen87 added the WebXR label Mar 7, 2025
@cabanier
Copy link
Contributor

cabanier commented Mar 7, 2025

@cabanier Can you give us a advice here? Is three.js using makeXRCompatible() correctly?

three.js/src/renderers/webxr/WebXRManager.js

Lines 391 to 395 in 537d396

if ( attributes.xrCompatible !== true ) {

await gl.makeXRCompatible();

}

Yes, this is the correct way of calling this function. (It's a no-op in the Quest Browser)
If this crashes, it points to a bug in Chromium and not the Quest Link runtime. cc @toji

@tjsc0
Copy link
Author

tjsc0 commented Mar 7, 2025

sometimes the first frame loads, but the scene is not updating, related bug report from 2021 #23058

Image

attaching some information from chrome://webxr-internals to aid with debugging:

Device Info

Property Value
Operating System Name Windows NT
Operating System Version 10.0.22631
GPU Gl Vendor Google Inc. (NVIDIA)
GPU GL Renderer ANGLE (NVIDIA, NVIDIA RTX A1000 6GB Laptop GPU (0x000025BC) Direct3D11 vs_5_0 ps_5_0, D3D11-32.0.15.7216)

Active Runtime

Device ID Supported Features Supports AR
OpenXR Device viewer, local, local-floor, bounded-floor, unbounded, anchors, secondary-views, hand-tracking, hit-test, light-estimation, depth-sensing false

XRSession Info

Trace ID Session State Attributes
5093721384540139164 Requested Mode: immersive-vrRequired Features: viewer, localOptional Features: bounded-floor, local-floorRequested Time: 3/7/2025, 1:03:53 PM
Started Device Id: OpenXR DeviceStarted Time: 3/7/2025, 1:03:54 PM

Frame Stats

1007, 2, 0, 30.41, 0.91, 25.47
2016, 0, 0, 0.00, 0.00, 0.00
3024, 0, 0, 0.00, 0.00, 0.00
4024, 0, 0, 0.00, 0.00, 0.00
5029, 0, 0, 0.00, 0.00, 0.00
6042, 0, 0, 0.00, 0.00, 0.00
7050, 0, 0, 0.00, 0.00, 0.00
8060, 0, 0, 0.00, 0.00, 0.00
9069, 0, 0, 0.00, 0.00, 0.00
10080, 0, 0, 0.00, 0.00, 0.00
11093, 0, 0, 0.00, 0.00, 0.00
12101, 0, 0, 0.00, 0.00, 0.00
13111, 0, 0, 0.00, 0.00, 0.00
14123, 0, 0, 0.00, 0.00, 0.00
15127, 0, 0, 0.00, 0.00, 0.00
16127, 0, 0, 0.00, 0.00, 0.00
17137, 0, 0, 0.00, 0.00, 0.00
18148, 0, 0, 0.00, 0.00, 0.00
19160, 0, 0, 0.00, 0.00, 0.00

@toji I would really appreciate it if you could take a look at this, please let me know if I could help in any way.

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

No branches or pull requests

3 participants