Skip to content

Commit 2680bae

Browse files
committed
Bugfix: Fix drag swizzle failing on wry 0.54+
- wry 0.54 switched from `declare_class\!` to `define_class\!`, which registers `WryWebView` lazily — the ObjC class doesn't exist until the first webview is instantiated - Moved `drag_image_detection::install()` from `setup()` to `RunEvent::Ready`, which fires after the webview is created
1 parent b3ff7ca commit 2680bae

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

  • apps/desktop/src-tauri/src

apps/desktop/src-tauri/src/lib.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,10 @@ pub fn run() {
286286
#[cfg(any(target_os = "macos", target_os = "linux"))]
287287
network::known_shares::load_known_shares(app.handle());
288288

289-
// Install drag image detection swizzle (macOS only)
290-
#[cfg(target_os = "macos")]
291-
drag_image_detection::install(app.handle().clone());
289+
// Drag image detection swizzle is installed in RunEvent::Ready (not here)
290+
// because wry 0.54+ registers the WryWebView ObjC class lazily — it doesn't
291+
// exist in the runtime until the first webview is created, which happens after
292+
// setup() returns.
292293

293294
// Observe system accent color changes and emit events to frontend
294295
#[cfg(target_os = "macos")]
@@ -888,12 +889,22 @@ pub fn run() {
888889
})
889890
.build(tauri::generate_context!())
890891
.expect("error while building tauri application")
891-
.run(|_app, event| {
892-
if let tauri::RunEvent::Exit = event {
893-
ai::manager::shutdown();
894-
mcp::stop_mcp_server();
895-
#[cfg(any(target_os = "macos", target_os = "linux"))]
896-
network::mdns_discovery::stop_discovery();
892+
.run(|app, event| {
893+
match event {
894+
tauri::RunEvent::Ready => {
895+
// Install drag image detection swizzle now that the webview exists.
896+
// wry 0.54+ registers WryWebView lazily, so it's only available after
897+
// the first webview is created (which happens between setup() and Ready).
898+
#[cfg(target_os = "macos")]
899+
drag_image_detection::install(app.handle().clone());
900+
}
901+
tauri::RunEvent::Exit => {
902+
ai::manager::shutdown();
903+
mcp::stop_mcp_server();
904+
#[cfg(any(target_os = "macos", target_os = "linux"))]
905+
network::mdns_discovery::stop_discovery();
906+
}
907+
_ => {}
897908
}
898909
});
899910
}

0 commit comments

Comments
 (0)