Fix Spector.js on Firefox by not initializing polyfill WebXR classes #285
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 thatenableXRCapture
still 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.