X Tutup
Skip to content

OpenXR: Prevent adding/removing extension wrappers after session start#109533

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
dsnopek:openxr-api-prevent-updating-extension-lists
Sep 30, 2025
Merged

OpenXR: Prevent adding/removing extension wrappers after session start#109533
Repiteo merged 1 commit intogodotengine:masterfrom
dsnopek:openxr-api-prevent-updating-extension-lists

Conversation

@dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Aug 11, 2025

This is related to my work on improving XR when Godot is rendering on a separate thread, but not entirely.

It is thread unsafe to add/remove extension wrappers from any of these Vector<T>s because both the render and main thread loop over them, especially in OpenXRAPI::end_frame() which runs on the render thread and can't have data change out from under it.

However, it's just unsafe in general to add/remove extension wrappers from these lists after an OpenXR session has started, even in a single-threaded context, because the state of all our OpenXR resources will get inconsistent if an extension wrapper runs some of its on_*() methods, but not all of them.

This PR aims to fix that!

There's two groups of extension lists:

  • The main list (modified by OpenXRAPI::register_extension_wrapper() and ::unregister_extension_wrapper()). This is the strictest case: we can't add or remove anything from this list after the OpenXR instance has been created (so, even before the session).
  • All the other lists, which are only used in OpenXRAPI::end_frame(). Those can't have any changes after the session has actually started (so, not just after the session has been created, but after the state has changed to XR_SESSION_STATE_READY). This is important because some pre-existing extensions add themselves to those lists right after the session is created (and remove themselves after the session is destroyed), and we need to not break them

I've tested this with the XR_FB_passthrough extension support from godot_openxr_vendors (which uses the composition_layer_providers list), and all seems good. But it could still use some testing with other extensions that use the other lists to make sure this doesn't break any of them.

@dsnopek dsnopek force-pushed the openxr-api-prevent-updating-extension-lists branch from bdea0a1 to 4a24de2 Compare August 22, 2025 13:04
@Repiteo Repiteo merged commit 7ca521e into godotengine:master Sep 30, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Sep 30, 2025

Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup