Bug at value gripRay.origin when exiting/re-entering Immersive mode

I’ve made a minimum, reproducible example that demonstrates a possible bug with WebXR.

Here is the Playground.

The following code is the core of the example:

const frameObserver = xrHelper.baseExperience.sessionManager.onXRFrameObservable.add(() => {
    if (motionController.handness === "right") {
        const gripRay = new BABYLON.Ray(new BABYLON.Vector3(), new BABYLON.Vector3());
        controller.getWorldPointerRayToRef(gripRay, true);
        console.log("gripRay.origin: " + gripRay.origin);
    }
});

That is, at each frame we print gripRay.origin for the right-hand controller. When I enter Immersive mode, the gripRay.origin is printed correctly:

img1

But, when I press the Oculus button to exit Immersive mode, then press the Continue button to re-enter Immersive mode, two kinds of values are printed in alternation: on the odd lines are printed the correct values for gripRay.origin, while on the even lines is printed the value of gripRay.origin at the moment we leaved Immersive mode the last time:

img2

The following image shows the moment in which we re-enter Immersive moment, which corresponds to the line at the center: we can see that at this line there is a circled “2”, which corresponds to the same value printed twice: at the last frame when we exit immersive-vr and at the first frame when we re-enter immersive-vr:

img3

In the following video I show how I reproduced the bug: first I enter the scene, placing the controller at the right, then press the Oculus button to exit immersive-vr, then move the controller at the left, and then re-entering immersive-vr:

Video - How to reproduce the bug

1 Like

Pinging @RaananW

1 Like

Seems to be a callback that is not cleared on our end. I probably missed disposing the observables when you end the session with native button.

Want to create a github issue? Will be better for me and you to track it on github.

1 Like

Sure! I’ll post it tomorrow.

1 Like