SteamVR killing client process in VR+NoVR Multiplayer

I have the SteamVR plugin enabled for engine and project, and after i package the game… I attempt to run 2 instances of the client on my pc. When the second instance loads, the first client instance is killed.

Very similar issue to this:

the above got me close… but this is not working for my packaged game.

I can run 2 client instances of my test project in the Editor.

  • On start you can select a VRPawn or ThirdPersonCharacter
  • In the editor everything works ok from there on with spawning, controls, etc…

When I package my game and run from command line, it does not work.

  • I launch dedicated server ./Test3PServer.sh /Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap -port=27017
  • launch client 1 ./Test3PClient.sh 127.0.0.1:27017 -nohmd -AudioMixer -ResX=1024 -ResY=768 -ForceRes -Windowed
  • launch client 2 ./Test3PClient.sh 127.0.0.1:27017 -AudioMixer -ResX=1024 -ResY=768 -ForceRes -Windowed

After client 2 has loaded my required vulkan extensions and goes to create the vulkan instance… the client 1 process is killed. (presumably by SteamVR).

It seems even with -nohmd SteamVR is “managing” my game process. How can I not have it do that?

My system:
Ubuntu 20.04.2 - Linux 5.11.0-40-generic
NVIDIA Titan RTX - 495.44 / CUDA 11.5 / Vulkan 1.2.131
Engine Version: 4.27.1
SteamVR beta 1.21.3

  • “Unchecked - Use Desktop Game Theatre while SteamVR is active”

More info … If i do not start SteamVR first

  • start my game dedicated server
  • then the -nohmd client
  • then attempt to start SteamVR

SteamVR does not open, it looks like it hangs and then just quits.

This happens because the engine needs to query the SteamVR plugin for which graphics adapter to use when the game launches, regardless if the game is set to enable VR on launch. The SteamVR plugin will initialize the OpenVR API as a scene application, and since SteamVR only supports a single scene application open at a time, it will quit all others.

It is possible to modify the SteamVR plugin to initialize as a background application when not starting the game in VR. This may cause failures if SteamVR is not running when the application launches though, since background applications will fail to initialize if SteamVR is not running.

Another option is to use OpenXR instead. It will not open SteamVR when starting up unless VR is enabled on launch.

1 Like

Thanks Rectus_SA your answer was very helpful. 1 follow up question for OpenXR:

  • My understanding is that it still requires an XR runtime (i.e. SteamVR). So I am not sure how that would also solve the problem? Are you suggesting i use an alternative runtime with my Valve Index? (i.e. Monado?)

On your first solution:
I was able to modify the Steam VR Plugin and run multiple client instances on the same machine. I could package a non-vr client build with this modification and a vr-client build without it. (But that just adds a build automation complexity that i would prefer to avoid… if there is an alternative solution with OpenXR)

VRSystem = vr::VR_Init(&VRInitErr, vr::VRApplication_Background);

https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Plugins/Runtime/Steam/SteamVR/Source/SteamVR/Private/SteamVRHMD.cpp#L235

Thanks!

For OpenXR, you can still use the SteamVR runtime. The issue is with how the SteamVR plugin in UE4 interacts withe the runtime, the OpenXR plugin does not have the same issue.

With the SteamVR modifications, you could tie whether to do the initial initialization in background mode with if the game is set to start in VR or not (or just disable runtime initialization). Note that if you want to switch the game to VR mode after launch with the runtime is initialized in background mode, you will need to shut it down and reinitialize it in scene mode.

1 Like

Thanks again Rectus_SA.

When i disable the SteamVR Plugin in the default VR Template, the HMD tracking works just fine! However, the Motion Controller tracking does not. I recall now, this is why i went down the SteamVR Plugin route in the first place haha.

The Motion controllers do not even appear in the game, i added a sphere as a component to the motion controller, and i dont even see that.

As for your suggestion regarding the SteamVR Plugin modifications, yea thats a way better idea than what i was planning with diff engine builds. I can get the IHeadMountedDisplay from the IXRTrackingSystem and check to see if it is enabled.

One thing to watch out for is that since version 1.21.1, the SteamVR beta has an extremely aggressive idle mode for the OpenXR runtime. The controllers do not start tracking until you put on the HMD, and opening the dashboard or taking the HMD off will immediately cut off tracking.

If that doesn’t help, it might be a good idea to check if the controllers track in other OpenXR apps, like the hello_xr example in the OpenXR SDK.

1 Like

Rectus_SA thank you again for all the help you provided!

I did a quick test with hello_xr from the OpenXR SDK using monado as runtime, and the motion controller tracking is working fine there. My cube hands move and rotate all around.

OpenXR seems to have no issue tracking those visual spaces. So unsure as to why the Index Controllers are not coming up as MotionControllers in UE4 VR Template.

Any pointers on where I can start to poke around in the UE4 openXR Plugin to debug?

As for the SteamVR Plugin alternative solution: For anyone looking at this thread later…here is the modification to the SteamVR Plugin that worked.

if (!FParse::Param(FCommandLine::Get(), TEXT("nohmd")))
{
     UE_LOG(LogHMD, Warning, TEXT("HMD Device is Enabled. Initializing VRSystem with vr::VRApplication_Scene"));
     VRSystem = vr::VR_Init(&VRInitErr, vr::VRApplication_Scene);
}
else
{
     UE_LOG(LogHMD, Warning, TEXT("HMD Device is Not Enabled. Initializing VRSystem with vr::VRApplication_Background"));
     VRSystem = vr::VR_Init(&VRInitErr, vr::VRApplication_Background);
}

Followup, the Motion Controllers in the VR Template are working now.

I simply registered the Monado SteamVR Drivers with SteamVR

https://monado.freedesktop.org/steamvr.html

1 Like