GodotVR / godot_openxr

(Maintenance mode) OpenXR drivers for the Godot Game Engine v3.x
MIT License
278 stars 45 forks source link

Application crashes following first successful run (Linux/SteamVR) #202

Open hellocld opened 2 years ago

hellocld commented 2 years ago

I have a very simple scene that runs fine on first launch, but subsequent attempts at running the scene result in a crash with the following message:

handle_crash: Program crashed with signal 11
Engine version: Godot Engine v3.4.4.stable.arch_linux
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /usr/lib/libc.so.6(+0x42560) [0x7f1539cb0560] (??:0)
[2] /home/crl/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrclient.so(+0x23f998) [0x7f150db32998] (??:0)
[3] /home/crl/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrclient.so(+0x1a2b1a) [0x7f150da95b1a] (??:0)
[4] /home/crl/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrclient.so(+0x21d6f9) [0x7f150db106f9] (??:0)
[5] /usr/lib/libc.so.6(+0x8d5c2) [0x7f1539cfb5c2] (??:0)
[6] /usr/lib/libc.so.6(clone+0x44) [0x7f1539d80584] (??:0)
-- END OF BACKTRACE --

If I quit SteamVR and relaunch it, I can successfully run the scene again once, but after that first run it'll continue to crash until I restart SteamVR again. This is on a new project, but I can reproduce the issue on projects I know were working without issue last year in the same environment.

ChristophHaag commented 2 years ago

Does it shut down properly the first time or does it quit with a crash? Wondering if it's https://github.com/ValveSoftware/SteamVR-for-Linux/issues/479

hellocld commented 2 years ago

There's no crash when I quit the first time. It does seem a lot like what's reported in the issue you linked to.

I'm just running the scene from within the editor via F6, and stopping it with F8. Is there a safer/cleaner way I should be stopping the scene?

BastiaanOlij commented 2 years ago

It would be good to try that out with a proper debug build so we get proper debug symbols. One thing I've been wanting to try is to move the call to loadActionSets to before initialiseSession, having had some discussions with Valve regarding some intermittent crash issues on Windows there might be an issue with the session accessing the action set data while we're still submitting data.

I remember moving that to after initialiseSession due to issues on Quest but they may have been related to other logic we already changed.

Just haven't had the time to try it yet as I've been having a few days off due to easter.

aleksfadini commented 2 years ago

I'm having the same issue. As a workaround, I kill all vr processes with pkill -9 -f vr And that allows me to start steamvr again without restarting my wm or rebooting. A bit of a chore, but it works.

I'm positing the crash occurs because godot does not shut down steamvr properly, so the second time it attemps to start it, an instance is already running. Killing it via terminal fixes that.

BastiaanOlij commented 2 years ago

@aleksfadini Godot will only clean up properly if it properly exits. If you kill the Godot process (which is what happens if you press the stop button in the editor to kill of the runtime) then it just exits right there and then without running through its proper exit process.

That also applies when pressing F8 as @hellocld mentions he does.

On Windows an application just suddenly disappearing triggers SteamVR to do the necessary cleanup and the OS cleans up memory etc.

To properly exit you need to call get_tree().quit()

hellocld commented 2 years ago

Thanks @BastiaanOlij! That makes for an easy enough workaround for now for me (added an autoload with a "quit" input that fires get_tree().quit(), can use that instead of killing the process for now).

aleksfadini commented 2 years ago

@hellocld that's a great workaround, thank you for bringing it up.

@BastiaanOlij thank you for clarifying, is there a way we can add this to the documentation for linux users or add the workaround to the plugin? Can I help? And thank you for the amazing plugin and the wonderful tutorial videos

aleksfadini commented 2 years ago

To properly exit you need to call get_tree().quit()

Just to clarify, this is not possible every time the project crashes (which happens often during debug). So for now on linux the following command is needed:

pkill -9 -f vr

before launching a scene, whenever the previous scene was terminated by a code error.

mnn commented 11 months ago

To properly exit you need to call get_tree().quit()

This doesn't work at all - it just freezes the game window. I also tried OS.kill(0) which closes the window, but also causes crashing on all subsequent runs. So far xkill works for me, but it is a quite cumbersome manual workaround. I'll either write some script to use the kill/pkill and bind it to a key, or postpone VR experiments in Godot.

Godot 4.1.1, i3wm, steamvr

ChristophHaag commented 11 months ago

SteamVR on linux hangs on xrDestroyInstance https://github.com/ValveSoftware/SteamVR-for-Linux/issues/422

mnn commented 11 months ago

SteamVR on linux hangs on xrDestroyInstance

I am confused, wouldn't that mean all VR applications (which use SteamVR) should freeze on exit? Why only Godot project freezes on exit, but no other VR application I tried?

amalon commented 10 months ago

SteamVR on linux hangs on xrDestroyInstance

I am confused, wouldn't that mean all VR applications (which use SteamVR) should freeze on exit? Why only Godot project freezes on exit, but no other VR application I tried?

Only applications which use the OpenXR API are affected. Many still use OpenVR.