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.
This commit is contained in:
l0ng-ai
2026-11-19 21:01:13 +08:00
committed by GitHub
parent e44e389571
commit b3f8cec272
+5 -2
View File
@@ -139,11 +139,14 @@ fn announce_available(app: &AppHandle) {
return;
}
let state = app.state::<AppState>();
// 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 = {