From 5ca8b4bb43c61bcaf9f1df319374f609d5fac087 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Wed, 17 Jun 2026 22:01:51 +0200 Subject: [PATCH] Cleanup active_runtime.json on start --- server/active_runtime.cpp | 16 ++++++++++++++++ server/active_runtime.h | 2 ++ server/main.cpp | 2 ++ 3 files changed, 20 insertions(+) diff --git a/server/active_runtime.cpp b/server/active_runtime.cpp index 539bbeec..eed9a345 100644 --- a/server/active_runtime.cpp +++ b/server/active_runtime.cpp @@ -238,4 +238,20 @@ active_runtime::~active_runtime() std::cerr << "Cannot unset active OpenVR runtime: " << e.what() << std::endl; } } + +void active_runtime::cleanup_openxr() +{ + for (const auto & manifest: manifest_path()) + { + auto active_runtime = xdg_config_home() / ("openxr/1/active_runtime" + get_abi(manifest) + ".json"); + std::error_code ec; + if (std::filesystem::equivalent(manifest, active_runtime, ec)) + { + std::cerr << "Removing stale file " << active_runtime << std::endl; + std::filesystem::remove(active_runtime, ec); + } + std::filesystem::rename(backup_name(manifest), manifest, ec); + } +} + } // namespace wivrn diff --git a/server/active_runtime.h b/server/active_runtime.h index 73cec731..087c269e 100644 --- a/server/active_runtime.h +++ b/server/active_runtime.h @@ -39,5 +39,7 @@ public: static std::vector manifest_path(); static std::filesystem::path openvr_compat_path(); + + static void cleanup_openxr(); }; } // namespace wivrn diff --git a/server/main.cpp b/server/main.cpp index dfa3e44a..2439909d 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -949,6 +949,8 @@ int inner_main(int argc, char * argv[], bool show_instructions) std::filesystem::create_directories(socket_path().parent_path()); + if (do_active_runtime) + active_runtime::cleanup_openxr(); listen_socket = create_listen_socket(); u_trace_marker_init();