Fix Spector.js on Firefox by not initializing polyfill WebXR classes#285
Merged
sebavan merged 1 commit intoBabylonJS:masterfrom Sep 11, 2023
Merged
Fix Spector.js on Firefox by not initializing polyfill WebXR classes#285sebavan merged 1 commit intoBabylonJS:masterfrom
sebavan merged 1 commit intoBabylonJS:masterfrom
Conversation
…unless we are using WebXR
c6410cb to
b6cbaa9
Compare
Contributor
Author
|
I have an alternate solution at dmliao@3a2e3b0 It has the similar principle of not defining modified WebXR API classes until WebXR is initialized, but keeps the classes in their own files (and also runs afoul of the one-class-per-file tslint rule, though that one uses class expressions only). Personally, I think either is fine, but you may have a stronger opinion on which style is better. Either way, WebXR capture won't be supported in Firefox, and it'll continue to fail at initialization. I can look deeper into that later if it'd be important to figure out. AppendixI've tried a number of other approaches, most of which were dead ends:
|
sebavan
approved these changes
Sep 11, 2023
Member
sebavan
left a comment
There was a problem hiding this comment.
looks all good to me, np for ts-lint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…until we initialize WebXR capture.
#257 enabled WebXR support for Spector.JS on Chrome, but broke Firefox because the polyfilled experimental WebXR APIs weren't implemented in Firefox, and module importing was trying to load them even if they were never being used.
This change fixes Spector.JS on Firefox by ensuring that the polyfilled WebXR APIs aren't even defined until Spector.JS is called with
enableXRCapture, so using it by default on Firefox will no longer cause problems. Note thatenableXRCapturestill won't work on Firefox, however.Caveats
While this is the simplest fix I could think of, it currently does not pass tslint, because of a limitation of 1 class per file. However, the current tsconfig also does not support dynamic imports (nor does the webpack configuration, I believe), which makes it otherwise difficult to ensure we don't try to access the WebXR APIs until they're needed in initialization.
(We can probably make an alternate version of this fix by polyfilling the WebXR apis without using classes, which will be more complex.)
Testing
I've verified that the samples once again work on Firefox, and I tested the WebXR samples against the Immersive Web Emulator on Chrome. I don't currently have access to a headset to do testing there.