# Game closes with HMD Plugged in

**URL:** <https://forums.unrealengine.com/t/game-closes-with-hmd-plugged-in/1322183>\
**Category:** XR Development\
**Tags:** htc, SteamVR, Virtual-Reality, unreal-engine, question, OpenXR\
**Created:** [October 4, 2023, 12:17pm UTC](https://forums.unrealengine.com/t/game-closes-with-hmd-plugged-in/1322183 "2023-10-04T12:17:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Univr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Univr](https://forums.unrealengine.com/u/Univr)\
**Post date:** [October 4, 2023, 12:17pm UTC](https://forums.unrealengine.com/t/game-closes-with-hmd-plugged-in/1322183/1 "2023-10-04T12:17:29Z")

</div>

Hi everyone !

I have some trouble with my project when I try to use OpenXR.  
For the context: I’ve exported some code we produced on a project which was running on UE4.23 and SteamVR and try to use it on UE4.27 with steam VR. Everything was fine until I try to run a build of the project: the controllers are not tracked and a window from SteamVR appears telling me that it needs keybinding for this project. I’ve read somewhere that new projects doesn’t works well with SteamVR, is that right ?

I tried with a project made from the VR template and everything works well, hands are tracked and no in game popup appears to ask for keybinding. So I chose to follow the settings of this project. I found out that this project doesn’t use the SteamVR plugin and use OpenXR instead. So I disabled the SteamVR plugin in my project.

The problem now is that the build closes almost instantly (it’s not crashing, it just closes itself). I dug into the engine to find out where the exit request is called and found the line, it’s from the OpenXRHMD.cpp file in the FOpenXRHMD::OnStartGameFrame(FWorldContext& WorldContext) method. It seems that the method catches an OpenXR event which is XR\_TYPE\_EVENT\_DATA\_INSTANCE\_LOSS\_PENDING which results in an exit request in build. I must have missed something but I don’t know what. The problem appears only if the headset is plugged in. Does someone have any idea ?

---

<div class="post-metadata">

**Author:** ![Univr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Univr](https://forums.unrealengine.com/u/Univr)\
**Post date:** [October 4, 2023, 3:14pm UTC](https://forums.unrealengine.com/t/game-closes-with-hmd-plugged-in/1322183/2 "2023-10-04T15:14:31Z")

</div>

Update !

I dug a bit more into the FOpenXRHMD::OnStartGameFrame() method with some breakpoint debug. I was wrong, it is a XR\_SESSION\_STATE\_EXITING of a XR\_TYPE\_EVENT\_DATA\_SESSION\_STATE\_CHANGED that was tringerring the exit request (i didn’t see that the break at the end of the case was conditionnally called.

At some point the ReadNextEvent method gets XR\_TYPE\_EVENT\_DATA\_SESSION\_STATE\_CHANGED and its state is XR\_SESSION\_STATE\_STOPPING which calls StopSession() which, I assume, raise state changed event with the XR\_SESSION\_STATE\_EXITING state leading to the exit request

---

<div class="post-metadata">

**Author:** ![Univr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Univr](https://forums.unrealengine.com/u/Univr)\
**Post date:** [October 4, 2023, 5:12pm UTC](https://forums.unrealengine.com/t/game-closes-with-hmd-plugged-in/1322183/3 "2023-10-04T17:12:55Z")

</div>

Ok, it was just a blueprint command node to disable stereo mode without any checks on the conditions to disable it.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [November 3, 2023, 5:13pm UTC](https://forums.unrealengine.com/t/game-closes-with-hmd-plugged-in/1322183/4 "2023-11-03T17:13:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
