WebXR on the HoloLens 2

Hi!

I’ve gotten this to work before but for some reason ever since I switched laptops I can’t get my WebXR project to work on the HoloLens anymore. It works on android :woman_shrugging:
I’ve tried clearing cookies in Edge, updating the HoloLens 2, rewriting the initialisation of the engine so I don’t rely on "babylonjs-hook" anymore but I’m still not getting the button to enable WebXR.

I am running this through https, that’s not the issue.
WebXR in general works on the device, if I start a simple example through a playground it works. The issue must be with something I’m doing, I just have no idea what I’m doing wrong here.

Version:

    "@babylonjs/core": "6.2.0",
    "@babylonjs/loaders": "6.2.0",

I’m hoping I’m just overlooking something, if anyone sees a problem let me know. Here’s how I’m initializing everything:

    const engine = new Engine(canvasRef.current, true, {xrCompatible: true}, true);
    function updateSize() {
        console.log("Resize")
        engine.resize();
      }
      
    window.addEventListener('resize', updateSize);
    const newScene = new Scene(engine);
    
    newScene.clearColor = new Color4(0.5,0.5,0.5,1);
    const camera = new ArcRotateCamera(
        "MainCamera",
        Tools.ToRadians(-90),
        Tools.ToRadians(70),
        Number(props.mxPreviewCameraDistance),
        new Vector3(0, 0, 0),
        newScene
    );
    camera.minZ = 0.1;
    new HemisphericLight("light", Vector3.Up(), newScene);
    setScene(newScene);
    camera.attachControl(canvasRef.current, true);
    const newParent = new Mesh("ContainerARParent", newScene);

    setParent(newParent);
    setParentID(newParent.uniqueId);
    engine.runRenderLoop(function () {
        newScene.render();
      });

    if (parent) {
        parent.rotation = Vector3.Zero();
    }

    const instantiateWebXR = async () => {
        const supported = await WebXRSessionManager.IsSessionSupportedAsync('immersive-ar');
        console.log("is immersive-ar supported? " + supported) // this gives supported as false 
        var defaultXRExperience = await newScene.createDefaultXRExperienceAsync({
            uiOptions: {
                sessionMode: 'immersive-ar'
            }
        } );
        if(!defaultXRExperience.baseExperience){
            console.log("No XR support")
        } else {
            // this is triggered, suggesting that there is a baseexperience
            console.log("XR supported, state: " + defaultXRExperience.baseExperience.state)
        }
    }
    instantiateWebXR();

cc @RaananW and @bghgary

I’ll check that. From first look everything seems to be ok
Have you tried vr instead of ar? Same result?

Oh odd, if I use immersive-vr it works, but if I then switch back to immersive-ar it doesn’t.

i just tried ar on edge and it works. want to share a playground that doesn’t work?

So far the playgrounds I’ve found do work. It’s definitely something in my setup but I don’t really know what or what to look for.

I’ll see if I can make a playground not work though, to maybe narrow it down. Thanks for the suggestions so far :smiley:

1 Like

Oh! no it doesn’t work in the playground. It worked when the session mode wasn’t specified (which I guess defaults to immersive-vr) but if you set it to immersive-ar specifically it doesn’t work.

Here’s one that doesn’t work:

Checking!

i’m in AR, it seems to work without an issue. what version of edge are you using?

112.0.1722.64 it says it’s up to date :woman_shrugging:

hmmm… weird. that should work. I have the same version. Is there any error you see when you hover over the enter-XR button (after it shows “ERROR”)?

That’s the thing there is no button, it only shows up when it’s in immersive-vr mode.

There is this message Session mode "immersive-ar" not supported in browser

can you try something for me - enable the webxr incubation flag on edge://flags (just in case it’s not on yet).

I see WebXR Incubations and WebXR Hand Input, they were on default, I’ve set them to enabled but I still get the same thing. Both in the playground and my own app it says Session mode "immersive-ar" not supported in browser. Maybe I accidentally clicked the wrong button on a permission at one time and it doesn’t prompt it again?

Oh you can just see the permissions, nothing has blocked AR permissions…

i’m on an insiders build, but AR has been enabled for quite some time now. I doubt it is the OS itself. Edge supports AR without a problem.
I can ask around and see if anyone has ever experienced this. Sorry, but I can’t think of a reason it would work on one system and not on another

Yeah I’m all out of ideas as well, thanks for the help I think I might just factory reset the device and hope that helps.

Reinstalling the OS also didn’t help, I think the problem might be in the build I also found this issue which might be the same as mine: augmented reality - Hololens 2 failing to provide Immersive AR/VR experience for WebXR - Stack Overflow

I think I’ll report the issue with the feedback app and just continue using ‘immersive-vr’ for now and hope it gets fixed :woman_shrugging:

1 Like

Sorry I can’t be of more help…

In case someone stumbles on this issue, it’s finally been fixed :sweat_smile:, apparently if you install the preview version:

Good news, we are tracking to a public release.

To help get to that date, we have a fix that is in the latest in-flight builds of HoloLens OS. If you have access to a test HoloLens device, you can get the latest build here that has the fix:

Insider preview for Microsoft HoloLens | Microsoft Learn

If anyone does go to insider preview to help test and works, please let me know here. If any issues, can hit up too.

1 Like