electron: [Bug]: WebXR API not working

Preflight Checklist

Electron Version

19.0.8

What operating system are you using?

Windows

Operating System Version

Windows 11 Pro 22000.795

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

Using the WebXR API successfully detects ‘immersive-vr’ as being supported.

The following is our react-based application running in Chrome version 103.

image

Actual Behavior

Using the WebXR API does not detect ‘immersive-vr’ as being supported.

image

Testcase Gist URL

No response

Additional Information

I was able to reproduce this behavior using Electron v19.0.8, v20.0.0-beta10, and a custom v21 nightly build with checkout_openxr explicitly set to True. I have also tried explicitly disabling the sandbox mode for the browser window as shown in the example below…

mainWindow = new BrowserWindow({
            backgroundColor: "#000",
            frame: false,
            width: Store.has("win.width") ? Store.get("win.width") : MIN_WIN_WIDTH,
            height: Store.has("win.height") ? Store.get("win.height") : MIN_WIN_HEIGHT,
            x: Store.has("win.x") ? Store.get("win.x") : undefined,
            y: Store.has("win.y") ? Store.get("win.y") : undefined,
            minWidth: MIN_WIN_WIDTH,
            minHeight: MIN_WIN_HEIGHT,
            webPreferences: {
                contextIsolation: false,
                nodeIntegration: false,
                preload: __dirname + "/preload.js",
                sandbox: false
            },
        });

Test code for detecting the VR support is as follows…

const [vrSupported, setVRSupported] = useState(true);

    useEffect(() => {
        if ("xr" in navigator) {
            //@ts-ignore
            navigator.xr.isSessionSupported('immersive-vr')
                .then((isSupported: boolean) => {
                    setVRSupported(isSupported);
                });
        }
    }, []);

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Per https://releases.electronjs.org/ Electron 19 is based on M102, can you try Electron 20 beta which is based on M104 and therefore will more likely align with your testcase of Chrome M103

Any updates on this issue, and in order to enable webXR for ElectronJS?

Pretty good blog post about this topic. https://bai.dev/projects/webxr-electron-apr2021.html

The main point being OpenXR is not included in the build of Electron so the WebXR api is disabled. Electron DEPS File

You can either make a local build of Electron like in the post or use NW.js which has WebXR enabled. NW.js DEPS File