# xrHelp.baseExperience.exitXRAsync =\> stuck in BABYLON.WebXRState.EXITING\_XR

**URL:** https://forum.babylonjs.com/t/xrhelp-baseexperience-exitxrasync-stuck-in-babylon-webxrstate-exiting-xr/9084
**Category:** Bugs
**Created:** [March 9, 2020, 11:10pm UTC](https://forum.babylonjs.com/t/xrhelp-baseexperience-exitxrasync-stuck-in-babylon-webxrstate-exiting-xr/9084 "2020-03-09T23:10:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jacob\_Durrant](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jacob_durrant/32/2052_2.png) [@Jacob\_Durrant](https://forum.babylonjs.com/u/Jacob_Durrant)
#### Post date: [March 9, 2020, 11:10pm UTC](https://forum.babylonjs.com/t/xrhelp-baseexperience-exitxrasync-stuck-in-babylon-webxrstate-exiting-xr/9084/1 "2020-03-09T23:10:48Z")

</div>

Recently ran into an issue that might be a bug. If you call `xrHelp.baseExperience.exitXRAsync()` when not in WebXR mode, BABYLON gets stuck perpetually in `BABYLON.WebXRState.EXITING_XR`. You cannot subsequently enter XR when you click on the XR helper button. Here’s a playground example:

[https://www.babylonjs-playground.com/#I0QDTA#4](https://www.babylonjs-playground.com/#I0QDTA#4)

On the other hand, if you first check to make sure you are not in XR mode, you can avoid this problem. Like this:

```auto
if (xrHelp.baseExperience.state === BABYLON.WebXRState.IN_XR) {
    xrHelp.baseExperience.exitXRAsync();
}

```

Why not have `xrHelp.baseExperience.exitXRAsync()` check this internally?

Thanks.

---

<div class="post-metadata">

### Author: ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)
#### Post date: [March 9, 2020, 11:12pm UTC](https://forum.babylonjs.com/t/xrhelp-baseexperience-exitxrasync-stuck-in-babylon-webxrstate-exiting-xr/9084/2 "2020-03-09T23:12:44Z")

</div>

Adding our VR GURU @RaananW to look into it.

---

<div class="post-metadata">

### Author: ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)
#### Post date: [March 10, 2020, 8:58am UTC](https://forum.babylonjs.com/t/xrhelp-baseexperience-exitxrasync-stuck-in-babylon-webxrstate-exiting-xr/9084/3 "2020-03-10T08:58:15Z")

</div>

Hurrah for state machines!

> [@Jacob\_Durrant](#):
>
> Why not have `xrHelp.baseExperience.exitXRAsync()` check this internally?

because it was simply not done? 🙂 I guess I never encountered this since I never called exit VR in code myself. Apart from a spectator ruining someone’s experiencing by exiting their experience or a VR user that has a GUI button to exit VR (instead of the dedicated button) I don’t see why you will need to call that…

Having said that - **this is clearly a bug** and I will fix it asap.

---

<div class="post-metadata">

### Author: ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)
#### Post date: [March 10, 2020, 1:27pm UTC](https://forum.babylonjs.com/t/xrhelp-baseexperience-exitxrasync-stuck-in-babylon-webxrstate-exiting-xr/9084/4 "2020-03-10T13:27:20Z")

</div>

PR submitted - [exit allowed only if already in XR by RaananW · Pull Request #7791 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/7791/)
