WebGL context must be marked as XR compatible

Hi! I’m experiencing problems trying to create an AR application. Everything was working fine, but today, I was working on the project and when I try to activate the camera to enter into the AR mode, it doesn’t work.

I tried to change the navigator (I tried Brave, Firefox and Chrome) and nothing works. Also tried different devices and also doesn’t work. I’ve created a new project with the template of ‘WebXR AR Starter Kit’ and when I try to activate the camera, gives the following error:

[playcanvas-1.63.4.js:67268]: Failed to construct ‘XRWebGLLayer’: WebGL context must be marked as XR compatible in order to use with an immersive XRSession.

Link to the base scene with the ‘WebXR AR Starter Kit’ from PlayCanvas: PlayCanvas | HTML5 Game Engine

I believe I have a fix here:

I’m not sure there’s a work around at the moment. We’ll try to release it soon.


I might have found a temporary solution waiting for the pull request’s merge that fixes the issue.
It is to manually make xr compatible from the app webgl before starting the xr from the camera.

const gl = this.app.graphicsDevice.gl;
await gl.makeXRCompatible();
// camera startXr

hope it helps.


Yes, it helps and it works. Thank you so much!