protonscr

[BUG] xrCreateSession and xrCreateSwapchain don't restore EGL context

steamvropen bug
ValveSoftware/SteamVR-for-Linux#821 · opened 2025-10-26 by amalon · updated 2026-07-17 · 1 comments · github
Aamalon 2025-10-26 github

Describe the bug
If the app's specified EGL context (via XR_MNDX_egl_enable extension) is not current when xrCreateSession or xrCreateSwapchain are called, those calls return with the EGL context changed to the app's EGL context. Whenever changing the EGL context, SteamVR should restore the previous value, as is now done for GLX, otherwise an app may legitimately assume the context isn't in use and attempt to eglMakeCurrent from another thread, which then fails with eglGetError() returning EGL_BAD_ACCESS.

(My notes indicate that prior to 1.16.2, linux_v1.14 switched GLX context but didn't restore, similar to this bug, but I think only for xrCreateSwapchain).

To Reproduce
Steps to reproduce the behavior:

  1. Use eglMakeCurrent() to clear the EGL context
  2. Call xrCreateSwapchain or xrCreateSession (using XR_MNDX_egl_enable)
  3. Use eglGetCurrentContext() and observe that the context has been altered

Expected behavior
eglGetCurrentContext() before and after these calls should always show the exact same value.

System Information (please complete the following information):
Please use the latest Steam beta client and SteamVR beta for your bug reports!

  • Steam client version (build number or date): Steam Beta Update, version 1761259186 (client build Oct 23 11:23 PM UTC -08:00)
  • SteamVR version: STEAMVR beta 2.13.6
  • Distribution (e.g. Ubuntu): ArchLinux
  • Mesa 25.2.4-arch1.2
Aamalon 2026-07-15 github

I've pushed an egl_context branch to https://gitlab.freedesktop.org/jameshogan/openxr-simple-example.git which adds a commit to reproduce this. It clears the EGL context before calling xrCreateSwapchain() and xrCreateSession(), then verifies its still clear afterwards.

Check EGL is being used:

Using EGL with context 0x559d33742020

SteamVR currently shows these warning messages:

EGL CONTEXT CHANGED (nil) to 0x559d33742020 by xrCreateSession()
EGL CONTEXT CHANGED (nil) to 0x559d33742020 by xrCreateSwapchain()
EGL CONTEXT CHANGED (nil) to 0x559d33742020 by xrCreateSwapchain()

Nothing extracted yet.