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

WebXRManager: Safely check for XRWebGLBinding. #30319

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

zonkypop
Copy link
Contributor

Description

When using the immersive-web-emulator XRWebGLBinding is undefined. The current code:

const useLayers = XRWebGLBinding !== undefined && 'createProjectionLayer' in XRWebGLBinding.prototype;

throws an error because it directly references XRWebGLBinding without checking if it is defined. I'm unsure whether all WebXR devices use XRWebGLBinding or if a PR would be better suited for their repo. This is a simple fix which resolves the issue when testing any of the WebXR demos using popular emulators.

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.52
79.1
339.53
79.09
+11 B
-7 B
WebGPU 490.85
136.4
490.85
136.4
+0 B
+0 B
WebGPU Nodes 490.32
136.29
490.32
136.29
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.41
112.15
465.42
112.15
+11 B
-6 B
WebGPU 561.43
152.1
561.43
152.1
+0 B
+0 B
WebGPU Nodes 516.81
141.67
516.81
141.67
+0 B
+0 B

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 14, 2025

/cc @toji

@Mugen87 Mugen87 changed the title Safely check for XRWebGLBinding WebXRManager: Safely check for XRWebGLBinding. Jan 14, 2025
@Mugen87 Mugen87 added this to the r173 milestone Jan 14, 2025
@Mugen87 Mugen87 merged commit 2cf6a5b into mrdoob:dev Jan 14, 2025
12 checks passed
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.

2 participants