Skip to content

Commit 90014a7

Browse files
committed
fix(desktop): await WebView recovery cleanup
Drive WebView recovery restart cleanup on the Tauri async runtime. Mark shutdown clean and request restart only after cleanup completes. Reuse the unified desktop exit flow for recovery dialog exits.
1 parent aff3284 commit 90014a7

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

src/apps/desktop/src/webview_recovery.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,7 @@ mod windows {
239239

240240
fn request_automatic_restart(app: &tauri::AppHandle) {
241241
log::warn!("Requesting controlled application restart for WebView2 recovery");
242-
crate::crash_diagnostics::mark_clean_shutdown("webview_recovery_restart");
243-
crate::save_main_window_state(app, "webview_recovery_restart");
244-
crate::perform_process_exit_cleanup();
245-
app.request_restart();
242+
request_controlled_restart(app, "webview_recovery_restart");
246243
}
247244

248245
fn show_escape_dialog(app: tauri::AppHandle) {
@@ -265,19 +262,27 @@ mod windows {
265262
request_user_restart(&app)
266263
}
267264
_ => {
268-
crate::crash_diagnostics::mark_clean_shutdown("webview_recovery_exit");
269-
crate::save_main_window_state(&app, "webview_recovery_exit_dialog");
270-
crate::perform_process_exit_cleanup();
271-
app.exit(1);
265+
crate::request_desktop_exit(&app, 1, "webview_recovery_exit");
272266
}
273267
});
274268
}
275269

276270
fn request_user_restart(app: &tauri::AppHandle) {
277-
crate::crash_diagnostics::mark_clean_shutdown("webview_recovery_user_restart");
278-
crate::save_main_window_state(app, "webview_recovery_user_restart");
279-
crate::perform_process_exit_cleanup();
280-
app.request_restart();
271+
request_controlled_restart(app, "webview_recovery_user_restart");
272+
}
273+
274+
fn request_controlled_restart(app: &tauri::AppHandle, reason: &'static str) {
275+
crate::save_main_window_state(app, reason);
276+
let app = app.clone();
277+
tauri::async_runtime::spawn(async move {
278+
crate::perform_process_exit_cleanup().await;
279+
crate::crash_diagnostics::mark_clean_shutdown(reason);
280+
log::info!(
281+
"Desktop restart authorized after graceful shutdown: reason={}",
282+
reason
283+
);
284+
app.request_restart();
285+
});
281286
}
282287

283288
fn map_failure_kind(kind: COREWEBVIEW2_PROCESS_FAILED_KIND) -> FailureKind {

0 commit comments

Comments
 (0)