From c08cc6d50041ec887d3070c41bb2c793dbac5155 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sun, 6 Mar 2022 18:44:12 -0300 Subject: [PATCH] fix(core): deadlock on focus events with invisible window,#3534 (#3622) Co-authored-by: Amr Bashir --- .changes/fix-window-creation-deadlock.md | 5 +++++ core/tauri-runtime-wry/src/lib.rs | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changes/fix-window-creation-deadlock.md diff --git a/.changes/fix-window-creation-deadlock.md b/.changes/fix-window-creation-deadlock.md new file mode 100644 index 000000000..9f88bcc97 --- /dev/null +++ b/.changes/fix-window-creation-deadlock.md @@ -0,0 +1,5 @@ +--- +"tauri-runtime-wry": patch +--- + +Fixes a deadlock on the `Focused` event when the window is not visible. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 037afaf30..1a5d882e9 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -2373,7 +2373,12 @@ fn handle_event_loop( .get(&window_id) .map(|w| &w.inner) { - webview.focus(); + // only focus the webview if the window is visible + // somehow tao is sending a Focused(true) event even when the window is invisible, + // which causes a deadlock: https://github.com/tauri-apps/tauri/issues/3534 + if webview.window().is_visible() { + webview.focus(); + } } }