From f4ed86d5f76bc4f52dcfec5f372023d175ba5e28 Mon Sep 17 00:00:00 2001 From: Kingsword Date: Tue, 13 May 2025 11:08:20 +0800 Subject: [PATCH 1/3] fix(window): ensure set_window_effects runs on main thread in WindowBuilder (#13422) --- .changes/fix-set-window-effects-main-thread.md | 18 ++++++++++++++++++ crates/tauri/src/window/mod.rs | 6 ++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 .changes/fix-set-window-effects-main-thread.md diff --git a/.changes/fix-set-window-effects-main-thread.md b/.changes/fix-set-window-effects-main-thread.md new file mode 100644 index 000000000000..0ed43c4a557b --- /dev/null +++ b/.changes/fix-set-window-effects-main-thread.md @@ -0,0 +1,18 @@ +--- +"@tauri-apps/api": "patch:bug" +"tauri-utils": "patch:bug" +"tauri-macos-sign": "patch:bug" +"tauri-bundler": "patch:bug" +"tauri-runtime": "patch:bug" +"tauri-runtime-wry": "patch:bug" +"tauri-codegen": "patch:bug" +"tauri-macros": "patch:bug" +"tauri-plugin": "patch:bug" +"tauri-build": "patch:bug" +"tauri": "patch:bug" +"@tauri-apps/cli": "patch:bug" +"tauri-cli": "patch:bug" +"tauri-driver": "patch:bug" +--- + +Fixed set_window_effects not runs on main thread in WindowBuilder. diff --git a/crates/tauri/src/window/mod.rs b/crates/tauri/src/window/mod.rs index ade440f763d5..e982ee0906f9 100644 --- a/crates/tauri/src/window/mod.rs +++ b/crates/tauri/src/window/mod.rs @@ -406,14 +406,12 @@ tauri::Builder::default() window.on_menu_event(handler); } - if let Some(effects) = self.window_effects { - crate::vibrancy::set_window_effects(&window, Some(effects))?; - } - let app_manager = self.manager.manager_owned(); let window_label = window.label().to_string(); + let window_ = window.clone(); // run on the main thread to fix a deadlock on webview.eval if the tracing feature is enabled let _ = window.run_on_main_thread(move || { + let _ = crate::vibrancy::set_window_effects(&window_, self.window_effects); let event = crate::EventName::from_str("tauri://window-created"); let payload = Some(crate::webview::CreatedEvent { label: window_label, From cfdb7680cf7e36e69f3531265f4b7f57a2720cb5 Mon Sep 17 00:00:00 2001 From: Kingsword Date: Tue, 13 May 2025 19:11:48 +0800 Subject: [PATCH 2/3] Update .changes/fix-set-window-effects-main-thread.md Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com> --- .changes/fix-set-window-effects-main-thread.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.changes/fix-set-window-effects-main-thread.md b/.changes/fix-set-window-effects-main-thread.md index 0ed43c4a557b..b9d7a2df8839 100644 --- a/.changes/fix-set-window-effects-main-thread.md +++ b/.changes/fix-set-window-effects-main-thread.md @@ -1,18 +1,5 @@ --- -"@tauri-apps/api": "patch:bug" -"tauri-utils": "patch:bug" -"tauri-macos-sign": "patch:bug" -"tauri-bundler": "patch:bug" -"tauri-runtime": "patch:bug" -"tauri-runtime-wry": "patch:bug" -"tauri-codegen": "patch:bug" -"tauri-macros": "patch:bug" -"tauri-plugin": "patch:bug" -"tauri-build": "patch:bug" "tauri": "patch:bug" -"@tauri-apps/cli": "patch:bug" -"tauri-cli": "patch:bug" -"tauri-driver": "patch:bug" --- Fixed set_window_effects not runs on main thread in WindowBuilder. From b0950461801d446bd782b298b5370933c3afbe5e Mon Sep 17 00:00:00 2001 From: Kingsword Date: Tue, 13 May 2025 19:27:50 +0800 Subject: [PATCH 3/3] fix: add window_effects check --- crates/tauri/src/window/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/tauri/src/window/mod.rs b/crates/tauri/src/window/mod.rs index e982ee0906f9..9c66ecbee98d 100644 --- a/crates/tauri/src/window/mod.rs +++ b/crates/tauri/src/window/mod.rs @@ -411,7 +411,9 @@ tauri::Builder::default() let window_ = window.clone(); // run on the main thread to fix a deadlock on webview.eval if the tracing feature is enabled let _ = window.run_on_main_thread(move || { - let _ = crate::vibrancy::set_window_effects(&window_, self.window_effects); + if let Some(effects) = self.window_effects { + _ = crate::vibrancy::set_window_effects(&window_, Some(effects)); + } let event = crate::EventName::from_str("tauri://window-created"); let payload = Some(crate::webview::CreatedEvent { label: window_label,