Skip to content

Conversation

@harryhjsh
Copy link
Contributor

Related: #31443 #30319 #30282 #31432

Description

Initialise the XRWebGLBinding as needed:

  • When layers are supported by the UA
  • When a granted session feature needs to make use of it (in WebXRManager)

A knock-on of this is that the Immersive Web Emulator and other webxr-polyfill consumers will work again (without needing to polyfill layers), but this is probably useful outside of that reason.

@github-actions
Copy link

github-actions bot commented Aug 14, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.9
79.1
338.96
79.12
+61 B
+19 B
WebGPU 575.21
158.73
575.35
158.75
+132 B
+26 B
WebGPU Nodes 573.82
158.49
573.95
158.51
+132 B
+26 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 470.64
113.87
470.7
113.89
+61 B
+20 B
WebGPU 646.28
174.8
646.42
174.83
+132 B
+31 B
WebGPU Nodes 600.46
163.98
600.59
164.01
+132 B
+30 B

@harryhjsh
Copy link
Contributor Author

harryhjsh commented Aug 14, 2025

N.B. I can't test camera-access or depth-sensing at the moment.

@harryhjsh
Copy link
Contributor Author

harryhjsh commented Aug 14, 2025

And just for posterity, the reason that this fixes the emulator is that Chrome doesn't implement layers (so supportsLayers == false and the binding is never created/can't throw). When/if Chrome does implement layers, the emulator/polyfilling without layers will break beyond our control (without more significant changes). Until then I feel like it's worth trying to keep it working where possible.

@Mugen87 Mugen87 added this to the r180 milestone Aug 15, 2025
@mikeskydev
Copy link
Contributor

I've tested camera access with this PR and can confirm everything's still working! Sorry for breaking all the emulators :-)

@harryhjsh
Copy link
Contributor Author

Thanks for the reviews + testing!

@Mugen87 Mugen87 merged commit 5a16f4b into mrdoob:dev Aug 15, 2025
9 checks passed
@harryhjsh harryhjsh deleted the glbinding-lazy-initialise branch August 15, 2025 09:54
this._referenceSpace = await session.requestReferenceSpace( this.getReferenceSpaceType() );

if ( this._supportsLayers ) {
if ( this._sessionUsesLayers ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere else uses this._sessionUsesLayers === true

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

Successfully merging this pull request may close these issues.

6 participants