fix(linux): reuse WebContext to prevent WebKitNetworkProcess leak (#14628)

Co-authored-by: Fabian-Lars <github@fabianlars.de>
This commit is contained in:
Kushal Meghani 2025-12-25 17:33:15 +05:30 committed by GitHub
parent 51a0d6d66d
commit c1d82eb3a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -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.

View File

@ -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);
}