Browse Source

fix(core): deadlock on focus events with invisible window,#3534 (#3622)

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Lucas Fernandes Nogueira 3 years ago
parent
commit
c08cc6d500
2 changed files with 11 additions and 1 deletions
  1. 5 0
      .changes/fix-window-creation-deadlock.md
  2. 6 1
      core/tauri-runtime-wry/src/lib.rs

+ 5 - 0
.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.

+ 6 - 1
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();
+          }
         }
       }