immersive-web / webxr-polyfill

Use the WebXR Device API today, providing fallbacks to native WebVR 1.1 and Cardboard
Apache License 2.0
381 stars 84 forks source link

Native WebXR API is enabled on Windows Chrome 78 if webxr-polyfill is loaded #109

Closed takahirox closed 4 years ago

takahirox commented 4 years ago

Probably it isn't a polyfill side problem but a browser side problem, but let me report a weird problem here so far.

Native WebXR API implemented by the browser seems being enabled on Windows Chrome 78 if webxr-polyfill is loaded even though WebXR API is disabled via chrome://flags.

How to reproduce

  1. Confirm WebXR API is disabled via chrome://flags
  2. Go to WebXR samples https://immersive-web.github.io/webxr-samples/immersive-vr-session.html
  3. Open web console
  4. Type XR, XRSession, or other XR*. You see "f XR() { [native code] }" which means they're declared inside of browser, not polyfill.
XR
-> ƒ XR() { [native code] }
XRSession
-> ƒ XRSession() { [native code] }

Update: Some other objects seem to be declared by polyfill, not browser.

XRWebGLLayer
-> ƒ (session, gl, options) {
        if (!options) {
          options = {};
        }
        options.compositionDisabled = (session._session_mode === "inline");
        return new originalXRLayer(sessi…

navigator.xr
-> XR$1 {Symbol(@@webxr-polyfill/EventTarget): {…}, Symbol(@@webxr-polyfill/XR): {…}, requestSession: ƒ}

Platform I tested on

jsantell commented 4 years ago

I've noticed this in the past if "Experimental Web Platform Features" was enabled in chrome://flags, even with WebXR disabled.

jsantell commented 4 years ago

XRWebGLLayer will also always be clobbered by the polyfill to fix Chrome 76-77 composite flag https://github.com/immersive-web/webxr-polyfill/blob/0fad13ef90060863f2a4ba66e969f4cff650797f/src/WebXRPolyfill.js#L163

takahirox commented 4 years ago

Thanks for the comment.

All flags are default on chrome://flags (= WebXR API is disabled)

All flags are default so experimental features is disabled. I explicitly disabled it, but I keep seeing the same issue.

And on other pages which don't importing webxr-polyfill, for example google.com XR* classes are undefined. Only on pages importing webxr-polyfill somehow native WebXR API seems being enabled.

Can you reproduce this issue in your side? (And does my bug report make sense?)

takahirox commented 4 years ago

Ah, realized it's because of origin-trial. Sorry for confusing!