Skip to content

The WebGL context was not marked as XR , when creating a medialayer in Meta Quest Browser. #31029

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

Open
danrossi opened this issue Apr 29, 2025 · 2 comments
Labels

Comments

@danrossi
Copy link
Contributor

Description

I am attempting to setup a createEquirectLayer media layer after XR session creation for Quest headsets. However I am seeing two faults and don't know where to report.

The first the browser is complaining makeXRCompatible isn't set even when called a second time. And then I get context loss which stops the session. On my integration it will stop the session automatically. On the test a timeout may prevent context loss.

Reproduction steps

  1. Start XR Session

Code

renderer.xr.addEventListener("sessionstart", async () => {
					const session = renderer.xr.getSession();
					

					if (XRMediaBinding !== undefined) {

                        await renderer.backend.makeXRCompatible();

                        mesh1.layers.disableAll();
			mesh2.layers.disableAll();

                        setTimeout(() => {
                            
                        //180
                        let angle = Math.PI;
                        
                        //360
                        angle = Math.PI*2;

						const mediaBinding = new XRMediaBinding( session );
						const equirectLayer = mediaBinding.createEquirectLayer(
							video,
							{
								space: renderer.xr.getReferenceSpace(),
								layout: 'stereo-left-right',
                                centralHorizontalAngle: angle, 
								//layout: 'stereo-top-bottom',
								// Rotate by 45 deg to avoid stereo conflict with the 3D geometry.
								transform: new XRRigidTransform(
									{},
									{ x: 0, y: .28, z: 0, w: .96 }
								)
							}
						);

						session.updateRenderState( {
							layers: [
								equirectLayer,
								...session.renderState.layers
							]
						});
                        }, 500);

					}

					if (session.supportedFrameRates) {
						console.log("supported framerates ", session.supportedFrameRates);
						session.addEventListener('frameratechange', (event) => {
							console.log("XRFrame rate is now " + session.frameRate)
						});

						session.updateTargetFrameRate(session.supportedFrameRates[session.supportedFrameRates.length - 1]).then((() => {
								
						})).catch(console.warn)
					}

					

				
				});

Live example

Screenshots

Image

Version

r176

Device

Headset

Browser

Chrome

OS

No response

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 30, 2025

How about you report this bug directly to Meta? AFAICS, this is about XRMediaBinding.createEquirectLayer() which is no three.js APIs.

@Mugen87 Mugen87 changed the title The WebGL context was not marked as XR , when creating a medialayer in Oculus Browser The WebGL context was not marked as XR , when creating a medialayer in Meta Quest Browser. Apr 30, 2025
danrossi added a commit to danrossi/three.js that referenced this issue Apr 30, 2025
@danrossi
Copy link
Contributor Author

I fixed the context loss fault with that branch adding to the initial render state. And deals with my initial feature request. I hope it's acceptable. But there is still a fault complaining about makeXRCompatible. I'll report to their forum.

@Mugen87 Mugen87 added the WebXR label May 1, 2025
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

2 participants