diff --git a/.changes/linux-webcontext.md b/.changes/linux-webcontext.md new file mode 100644 index 000000000..0a14638d3 --- /dev/null +++ b/.changes/linux-webcontext.md @@ -0,0 +1,5 @@ +--- +tauri-runtime-wry: patch:bug +--- + +On Linux, keep the WebContext alive to prevent zombie WebKit processes after repeatedly closing all windows and re-opening them. diff --git a/crates/tauri-runtime-wry/src/lib.rs b/crates/tauri-runtime-wry/src/lib.rs index 6b919e746..821fbacec 100644 --- a/crates/tauri-runtime-wry/src/lib.rs +++ b/crates/tauri-runtime-wry/src/lib.rs @@ -2422,6 +2422,18 @@ impl Drop for WebviewWrapper { if let Some(web_context) = context_store.get_mut(&self.context_key) { web_context.referenced_by_webviews.remove(&self.label); + // https://github.com/tauri-apps/tauri/issues/14626 + // Because WebKit does not close its network process even when no webviews are running, + // we need to ensure to re-use the existing process on Linux by keeping the WebContext + // alive for the lifetime of the app. + // WebKit on macOS handles this itself. + #[cfg(not(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" + )))] if web_context.referenced_by_webviews.is_empty() { context_store.remove(&self.context_key); }