ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.13k stars 1.28k forks source link

Proper way to shutdown Steamvr? #611

Open ghost opened 7 years ago

ghost commented 7 years ago

I've had some issues with shutting down SteamVR. Currently I am using a script to find the vrmonitor, vrcompositor, and vrserver processes PIDs and sending them a SIGKILL (9) signal. However this only works about 70% of the time.

For whatever reason the said processes can become zombie processes or just refuse to shutdown.

Whenever I try to run a program again it will crash because you can only have one instance running at a time. There has got to be a better way.

I am using a Ubuntu 16.04 (Linux) OS with a HTC Vive. If additional details are needed I can provide them.

LoSealL commented 7 years ago

I'm not familiar with Linux, let me try to make some explanation in Windows.

Say vrserver.exe is the first startup process, it will send IPC signal to vrmonitor and vrcompositor. If the latter two processes recved the signal, they will work properly, otherwise they will time out and exit.

On exit, vrserver still sends exiting signal to those processes to make them exit. So if your vrserver crashes or IPC is blocked somehow, no signal will broadcast to vrcompositor as well as vrmonitor and they become zombies.

ghost commented 7 years ago

@LoSealL I see that makes a lot of sense now. But then what does steamtours do then?

vilg commented 7 years ago

Bump, I was trying to shutdown steamvr just by killing vrmonitor.exe process. But many times it occurs a steamvr compositor bug - appear a message that "SteamVR compositor is needed to steamvr work properly". What I can do is only quit steamvr by right-click -> quit or reboot computer. I am not linux user like @1Presidio, I am using Windows 10 64bit.

So, is there any way to programmatically simulate pressing right-click on steamvr and then quit? Any proccess message or something like that?

LoSealL commented 7 years ago

@1Presidio steamtours is the Steam Home Beta program, which is the welcome scene. You can simply treat it as a running game. @vilg if you are using a controller, holding the system button will show exit menu. In my option, exit program without user's interaction is a bad idea...

TheDeveloperGuy commented 7 years ago

There's an event you can send to quit SteamVR. I can't remember offhand, but it's in the header file and has been confirmed to be "OK" to use by Valve devs.

LoSealL commented 7 years ago

@TheDeveloperGuy you mean VREvent_DriverRequestedQuit ?

TheDeveloperGuy commented 7 years ago

Yes. See this for details: https://github.com/ValveSoftware/openvr/issues/473

LoSealL commented 7 years ago

@TheDeveloperGuy Thanks