Failed to construct 'XRWebGLBinding': parameter 1 is not of type 'XRSession'."

Godot Version

4.3

Question

I’ve been trying to experiment with WebXR (and HTML5 exports) in Godot lately. I’ve followed several tutorials and read what I could find in the documentation about it.

This error message pops up in the web browser when I attempt to run it:

“Unable to enter VR: Unable to make WebGL context compatible with WebXR: TypeError: Failed to construct ‘XRWebGLBinding’: parameter 1 is not of type ‘XRSession’.”

The function that prints the error message is easy enough to hunt down in the XR Tools add on but I can’t seem to track down where it is being called from.

I’ve had no luck on Google trying to hunt down a solution. Could anyone kindly point me in a direction to where I could search this out to understand better what’s causing the issue and how to resolve it?

1 Like

I was following @dsnopek tutorial here on Godot 4.3 just like you!

I couldn’t get it to work on Firefox because of some shader error:

USER ERROR: SceneShaderGLES3: Vertex shader compilation failed: tmp_js_export.js:474:18
ERROR: 0:31: 'GL_OVR_multiview2' : extension is not supported tmp_js_export.js:474:18
ERROR: 0:31: '?' : Error during layout qualifier parsing. tmp_js_export.js:474:18
ERROR: 0:482: 'gl_ViewID_OVR' : undeclared identifier tmp_js_export.js:474:18
ERROR: 0:482: '[]' : integer expression required tmp_js_export.js:474:18
ERROR: 0:483: 'gl_ViewID_OVR' : undeclared identifier tmp_js_export.js:474:18
ERROR: 0:483: '[]' : integer expression required tmp_js_export.js:474:18
ERROR: 0:484: 'gl_ViewID_OVR' : undeclared identifier tmp_js_export.js:474:18
ERROR: 0:484: '[]' : integer expression required tmp_js_export.js:474:18
<empty string> tmp_js_export.js:474:18
   at: _display_error_with_code (drivers/gles3/shader_gles3.cpp:254) tmp_js_export.js:474:18
USER ERROR: Method/function failed. tmp_js_export.js:474:18
   at: _compile_specialization (drivers/gles3/shader_gles3.cpp:348) tmp_js_export.js:474:18
WebGL warning: framebufferTexture2D: `tex` cannot be rebound to a new target. 2
WebGL warning: checkFramebufferStatus: Framebuffer not complete. (status: 0x8cd7) 
WebGL warning: framebufferTexture2D: `tex` cannot be rebound to a new target. 2
WebGL warning: drawArraysInstanced: Tex image TEXTURE_2D_ARRAY level 0 is incurring lazy initialization.
WebGL warning: framebufferTexture2D: `tex` cannot be rebound to a new target. 26
After reporting 32, no further warnings will be reported for this WebGL context.

and couldn’t get it to work on Chromium because of some complaint about stereoscopic error:

USER WARNING: Object picking can't be used when stereo rendering, this will be turned off!
at: _process_picking (scene/main/viewport.cpp:696)

When I removed the extra head include:

<script src="https://cdn.jsdelivr.net/npm/webxr-polyfill@latest/build/webxr-polyfill.min.js"></script>
<script>
var polyfill = new WebXRPolyfill();
</script>
<script src="https://cdn.jsdelivr.net/npm/webxr-layers-polyfill@latest/build/webxr-layers-polyfill.min.js"></script>
<script>
var layersPolyfill = new WebXRLayersPolyfill();
</script>

and instead received the same error you got with a message prompt on Chromium:

Failed to initialize: Unable to make WebGL context compatible with WebXR: TypeError: Failed to construct 'XRWebGLBinding': parameter 1 is not of type 'XRSession'.

and this text prompt on Firefox:

Failed to initialize: Unable to make WebGL context compatible with WebXR: ReferenceError: XRWebGLBinding is not defined

Hi!

Looking at your error messages, the most important message is this one:

This means multiview isn’t supported, and unfortunately, stereo rendering in Godot 4 depends on multiview. Assuming we’re talking about desktop Firefox and Chrome, then my guess is that it’s your GPU that doesn’t support multiview. If we’re talking about mobile browsers, there’s a few that don’t support multiview even when the GPU does have support for it.

I really would like to explore supporting non-multiview stereo rendering in Godot 4, like we had in Godot 3, but haven’t had the time to dig into it yet.

1 Like

Ah no worries, thanks for sharing! I actually got it working on my phone! But that means that I can’t debug on the desktop and would need to export and connect my phone to the computer to actually test :confused:

Still, thank you for all the hard work and good luck for the push into Godot 4 :slight_smile: