KhronosGroup / KhronosGroup/OpenXR-SDK-Source

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

Open
#301 1 comment 0 reactions 0 assignees View on GitHub
synced to gitlab
Dominant language
Python
Stars
825
Forks
306
Avg merge
1d 23h
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in the hello_xr shutdown path and compare the requested Unix signal() and Windows SetConsoleCtrlHandler() approaches. Define completion as ctrl-c allowing OpenXR resources such as swapchains and spaces to be destroyed cleanly without hanging, while supporting the relevant platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
ar-vr-xr
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.