MozillaReality / WebXR-emulator-extension

WebXR emulator extension
Mozilla Public License 2.0
454 stars 55 forks source link

makeXRCompatible() doesn't work on (Windows) Chrome 88 #266

Closed takahirox closed 3 years ago

takahirox commented 3 years ago

On Windows Chrome 88, WebGL(2)RenderingContext.makeXRCompatible() throws an exception.

const canvas = document.createElement('canvas');
const context = canvas.getContext('webgl2');
context.makeXRCompatible().then(result => {
  console.log(result);
}).catch(error => {
  console.error(error);
});
-> DOMException: An attempt was made to use an object that is not, or is no longer, usable.

It seems context.makeXRCompatible() became to throw an exception on Chrome 88 if no immersive XR device is connected. IIRC, the method resolved on Chrome 87 and before.

According to the WebXR specification the new context.makeXRCompatible() behavior on Chrome 88 seems correct. So I speculate it is intentional.

https://www.w3.org/TR/webxr/#contextcompatibility

I'm thinking to resolve this problem and emergently release 0.3.2. Otherwise JS VR engines/apps including await context.makeXRCompatible() for example Three.js dev branch may not work with the extension on Chrome 88 or newer.

An easy workaround for users would be using Firefox for now.