question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

webXR shows "AR session supported" on unsupported device

See original GitHub issue

Describe the bug This phone does not have ar-core support , but the start ar buttons is present & navigator.xr.isSessionSupported('immersive-ar') returns true

but clicking on the button asks camera permissions then crashes (screenshot has error message)

Expected behavior

This device does not support google ar core , so navigator.xr.isSessionSupported('immersive-ar') should return false as AR experiences on Android can only be run on an ARCore supported device.

Screenshots XR

Platform:

  • Device: [Mobile: Samsung galaxy M30]
  • OS: [Android]
  • Browser: [Chrome]
  • Three.js version: [r135]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jynxiocommented, Nov 22, 2021

Summary

This error comes from WebXR API, not three.js (I think) .

details

Based on my experience, When the test machine meets the following 2 conditions, navigator.xr.isSessionSupported('immersive-ar') will always return true (fulfilled) : ① phone ② https Otherwise it will return false.

When I use a mobile phone (not supporting ARcore) to visit a WebXR site that uses https, the following events will occur in sequence: ① navigator.xr.isSessionSupported('immersive-ar') will return true(fulfilled) ② A pop-up box in the middle of Chrome asks me “whether to grant AR permissions to the site” (If the user has granted this permission to the site, this step will not appear) ③ I allow to grant AR permissions to this site ④ The pop-up box at the bottom of Chrome says “ARCORE needs to be installed” ⑤ I click “install” ⑥ After a short loading animation, the phone jumps to the ARCORE download page of the App store (Some phones may not automatically redirect to the App store, this is most likely because ARCore is not listed on the App Store of this phone, at this time, you can only download ARcore on Google Play by yourself) ⑦ Install ARCore ⑧ The App Store pop-up prompts “The app is not adapted to your device, and abnormal conditions such as freezes and flashbacks may occur during operation. It is recommended to wait for the app developer to solve the adaptation problem before trying to install.” (This is why you see “crashes”) ⑨ Restart the site and start the AR program (immersive-ar) ⑩ crashes

Obviously, this bug (navigator.xr.isSessionSupported('immersive-ar') will always return true on phone that do not support ARCore) comes from the WebXR API. It should not be fixed by modifying three.js, the bug has nothing to do with the device (I think) .

Code


check().then(is_supported => {

    if (!is_supported) {

        button.textContent = "Not Support";

        return;

    }

    button.textContent = "Open";
    button.addEventListener("click", _ => {

        navigator.xr.requestSession("immersive-ar", {}).then(session => {

            renderer.xr.setReferenceSpaceType("local");
            renderer.xr.setSession(session);

        });

    });

});

function check() {

    return (new Promise(function (resolve) {

        const is_support_https = _checkHttps();

        if (!is_support_https) {

            resolve(false);

            return;

        }

       _ checkImmersiveAr().then(resolve);

    }));

};

function _checkHttps() {

    return window.isSecureContext;

}

function _checkImmersiveAr() {

    return (new Promise(function (resolve) {

        if (!("xr" in window.navigator)) {

            resolve(false);

            return;

        }

        navigator.xr.isSessionSupported("immersive-ar").then(resolve);

    }));

}

Most of the code related to “three.js” is omitted

Other

I have a device that supports ARCore, which can run the WebXR application built by the above code normally

1reaction
Mugen87commented, Nov 22, 2021

Closing then. I’m not sure where it’s best to report this issue but the browser vendor might be a good start.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Starting up and shutting down a WebXR session - Web APIs
This object represents the overall WebXR device suite available to ... It introduced support for augmented reality (AR) through the WebXR AR ......
Read more >
immersive-ar samples not working · Issue #61 - GitHub
Attached debugger shows XRSession creation failed: The specified session configuration is not supported. Hi Mate! Same problem here! Dis you ...
Read more >
WebXR requirements | ARCore - Google Developers
AR experiences on Android can only be run on an ARCore supported device. Ensure that the device has Google Play Services for AR...
Read more >
WebXR Device API Explained - Immersive Web
The WebXR Device API provides access to input and output capabilities commonly associated with Virtual Reality (VR) and Augmented Reality (AR) devices.
Read more >
WebXR Device API - W3C
A session mode of immersive-vr indicates that the session's output will be given exclusive access to the immersive XR device display and that ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found