OpenXR-SDK-Source icon indicating copy to clipboard operation
OpenXR-SDK-Source copied to clipboard

Request: trap ctrl-c in hello_xr, shutdown openxr cleanly

Open fredemmott opened this issue 4 years ago • 1 comments

As well as being a 'hello, world' demo app, hello_xr is useful as a quick-launching test app when working on API layers (in my case, https://github.com/fredemmott/OpenKneeboard). For this case, it would be useful to make it a bit more 'well behaved'.

I tried using a std::unique_ptr<> to hold my resources, and calling xrDestroyFoo() from my destructor

This makes hello_xr hang forever on ctrl-c, inside my calls to xrDestroySwapchain or xrDestroySpace; this seems to be because the openxr resources/functions have already been unloaded before my API layer's DLL is unloaded, and in turn, before my static std::unique_ptr's destructor is called.

To workaround, I'm using a raw pointer, and delete'ing from my xrDestroySession override, which effectively leaks the resources on shutdown; this isn't directly a problem, but in general, it's good to be able to use RAII instead of raw pointers where possible.

This could be done via signal() on unix-like platforms, or SetConsoleCtrlHandler() on windows

fredemmott avatar Apr 05 '22 15:04 fredemmott

An issue (number 1687) has been filed to correspond to this issue in the internal Khronos GitLab (Khronos members only: KHR:openxr/openxr#1687 ), to facilitate working group processes.

This GitHub issue will continue to be the main site of discussion.

rpavlik-bot avatar Apr 07 '22 14:04 rpavlik-bot