From b3f8cec272f893984b5840d3d391c01a38ffbeae Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Thu, 19 Nov 2026 21:01:13 +0800 Subject: [PATCH] fix(updates): don't hold the update lock while asking which window is focused (#4523) The automatic update announcement held updates.ready while asking a window whether it is focused (a main-thread round trip); a window starting up ran app_update_window_ready on the main thread and waited for the same lock, freezing startup with no window. The focused and live windows are now read before taking the lock. --- src-tauri/src/updates.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/updates.rs b/src-tauri/src/updates.rs index fe714bcbd..a3d530446 100644 --- a/src-tauri/src/updates.rs +++ b/src-tauri/src/updates.rs @@ -139,11 +139,14 @@ fn announce_available(app: &AppHandle) { return; } let state = app.state::(); + // Asking a window whether it is focused waits for the main thread, where + // `app_update_window_ready` takes `ready`: never hold the lock across it. + let focused = crate::windows::target_window(app); + let live = crate::windows::project_window_labels(app); let owner = { let mut ready = state.updates.ready.lock(); ready.retain(|label| app.get_webview_window(label).is_some()); - let focused = crate::windows::target_window(app); - ready_owner(focused.as_ref().map(|window| window.label()), &crate::windows::project_window_labels(app), &ready) + ready_owner(focused.as_ref().map(|window| window.label()), &live, &ready) }; let Some(owner) = owner else { return }; let update = {