Skip to content

openxr_data: fire VREvent_Quit event when session state changes to STOPPING#230

Open
ImSapphire wants to merge 3 commits intoSupreeeme:mainfrom
ImSapphire:quit-on-session-loss
Open

openxr_data: fire VREvent_Quit event when session state changes to STOPPING#230
ImSapphire wants to merge 3 commits intoSupreeeme:mainfrom
ImSapphire:quit-on-session-loss

Conversation

@ImSapphire
Copy link
Contributor

@ImSapphire ImSapphire commented Nov 17, 2025

Tested in VRChat via closing with WiVRn's quit button.

@ImSapphire ImSapphire requested a review from Supreeeme November 27, 2025 07:06
@ImSapphire ImSapphire force-pushed the quit-on-session-loss branch 2 times, most recently from 1537d95 to 273ad97 Compare November 27, 2025 08:16
@Supreeeme
Copy link
Owner

Sorry for the delay. Looks good, but a test for this would be cool.

@ImSapphire ImSapphire force-pushed the quit-on-session-loss branch from 273ad97 to 06a5c92 Compare December 3, 2025 07:20
@ImSapphire
Copy link
Contributor Author

ImSapphire commented Dec 3, 2025

Sorry for the delay. Looks good, but a test for this would be cool.

I'm not exactly sure how to write unit tests, and I'm working on some other things right now, would it be fine to merge without a test?

@Supreeeme
Copy link
Owner

  1. I realized this is actually session loss, not instance loss. The commit message should probably be reworded.
  2. I was thinking about this and came to a realization: is telling the application on session loss really the right thing here? To me VREvent_Quit seems more like a way to tell an application to gracefully close, but session loss seems closer to an error condition, and if we have applications gracefully exit it won't be obvious something erroneous happened. I would think session state being STOPPING or EXITING would be more appropriate.

@ImSapphire
Copy link
Contributor Author

@Supreeeme Would emitting VREvent_Quit event on change to STOPPING state be enough? I thought there would be more involved in that case, though I guess nothing in OpenXR mandates that the app stop immediately

@ImSapphire ImSapphire force-pushed the quit-on-session-loss branch from 06a5c92 to 40b491b Compare December 8, 2025 08:12
@ImSapphire ImSapphire changed the title openxr_data: fire VREvent_Quit event when instance loss is pending openxr_data: fire VREvent_Quit event when session state changes to STOPPING Dec 8, 2025
@Supreeeme
Copy link
Owner

Based on the spec, I think the correct thing to do would be:

  1. Send VREvent_Quit on STOPPING
  2. Call end_session (xrEndSession) when the application calls AcknowledgeQuit_Exiting

@ImSapphire
Copy link
Contributor Author

iirc in SteamVR, AcknowledgeQuit_Exiting just extends SteamVR's kill timer to give the app time to safely shutdown, if we stop the session there we'd probably crash because the game would keep calling functions like WaitGetPoses, Get*ActionData etc. Not sure what the right thing to do there is

@ImSapphire
Copy link
Contributor Author

Some apps also simply don't call AcknowledgeQuit_Exiting (VRChat, Resonite from what I've tested so far)

@ImSapphire
Copy link
Contributor Author

Added a test

@ImSapphire ImSapphire force-pushed the quit-on-session-loss branch from b7072eb to 666dbc2 Compare January 15, 2026 03:22
@ImSapphire ImSapphire force-pushed the quit-on-session-loss branch from 666dbc2 to 0d8d322 Compare February 4, 2026 04:56
@ImSapphire
Copy link
Contributor Author

@Supreeeme is there anything I could do to get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants