From 337cfdb3f8147983f5e1435f1fae863dd34739cc Mon Sep 17 00:00:00 2001 From: Schmarni Date: Sat, 24 Jan 2026 12:42:18 +0100 Subject: [PATCH] fix(openxr): fix frametime recovery on WiVRn (and probably other monado runtimes) Signed-off-by: Schmarni --- crates/bevy_openxr/src/openxr/render.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/crates/bevy_openxr/src/openxr/render.rs b/crates/bevy_openxr/src/openxr/render.rs index 6af4f86..02342f3 100644 --- a/crates/bevy_openxr/src/openxr/render.rs +++ b/crates/bevy_openxr/src/openxr/render.rs @@ -283,7 +283,11 @@ pub fn insert_texture_views( mut swapchain: ResMut, mut manual_texture_views: ResMut, graphics_info: Res, + frame_state: Res, ) { + if !frame_state.should_render { + return; + } let index = swapchain.acquire_image().expect("Failed to acquire image"); let image = &swapchain_images[index as usize]; @@ -293,10 +297,12 @@ pub fn insert_texture_views( } } -pub fn wait_image(mut swapchain: ResMut) { - swapchain - .wait_image(openxr::Duration::INFINITE) - .expect("Failed to wait image"); +pub fn wait_image(mut swapchain: ResMut, state: Res) { + if state.should_render { + swapchain + .wait_image(openxr::Duration::INFINITE) + .expect("Failed to wait image"); + } } pub fn add_texture_view( @@ -325,7 +331,10 @@ pub fn begin_frame(mut frame_stream: ResMut) { frame_stream.begin().expect("Failed to begin frame"); } -pub fn release_image(mut swapchain: ResMut) { +pub fn release_image(mut swapchain: ResMut, state: Res) { + if !state.should_render { + return; + } #[cfg(target_os = "android")] { let ctx = ndk_context::android_context();