From af8a062b573df1553d0d8973208b87362e75c063 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sat, 8 Nov 2025 15:46:52 -0500 Subject: [PATCH] feat: enhance sdxr_start with retry logic for fusion client connection and improved error handling --- bridge/src/lib.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/bridge/src/lib.rs b/bridge/src/lib.rs index 5b61a90..e8cab1b 100644 --- a/bridge/src/lib.rs +++ b/bridge/src/lib.rs @@ -183,13 +183,27 @@ pub extern "C" fn sdxr_start(app_id: *const std::os::raw::c_char) -> i32 { } }); println!("[bridge] Connecting to Stardust server..."); - let mut client = match stardust_xr_fusion::client::Client::connect().await { - Ok(c) => c, - Err(e) => { eprintln!("[bridge] Fusion connect failed: {:?}", e); return; } + // Retry fusion connect for a few seconds to handle compositor wake-up races. + let mut client = loop { + match stardust_xr_fusion::client::Client::connect().await { + Ok(c) => break c, + Err(e) => { + eprintln!("[bridge] Fusion connect failed: {:?}; retrying...", e); + tokio::time::sleep(std::time::Duration::from_millis(500)).await; + if STOP_REQUESTED.load(Ordering::SeqCst) { return; } + } + } }; let dbus_connection = match fusion_connect_client().await { Ok(c) => c, - Err(e) => { eprintln!("[bridge] DBus connect failed: {:?}", e); return; } + Err(e) => { + eprintln!("[bridge] DBus connect failed: {:?}; continuing without context extras", e); + // Fallback to a new connection attempt with default + match fusion_connect_client().await { + Ok(c2) => c2, + Err(_) => return, + } + } }; let accent_color = AccentColor::new(dbus_connection.clone()); let context = Context { dbus_connection, accent_color };