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..b9d7a2df8839 --- /dev/null +++ b/.changes/fix-set-window-effects-main-thread.md @@ -0,0 +1,5 @@ +--- +"tauri": "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..9c66ecbee98d 100644 --- a/crates/tauri/src/window/mod.rs +++ b/crates/tauri/src/window/mod.rs @@ -406,14 +406,14 @@ 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 || { + 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,