Skip to content

Commit c1d82eb

Browse files
fix(linux): reuse WebContext to prevent WebKitNetworkProcess leak (#14628)
Co-authored-by: Fabian-Lars <github@fabianlars.de>
1 parent 51a0d6d commit c1d82eb

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

.changes/linux-webcontext.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tauri-runtime-wry: patch:bug
3+
---
4+
5+
On Linux, keep the WebContext alive to prevent zombie WebKit processes after repeatedly closing all windows and re-opening them.

crates/tauri-runtime-wry/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,6 +2422,18 @@ impl Drop for WebviewWrapper {
24222422
if let Some(web_context) = context_store.get_mut(&self.context_key) {
24232423
web_context.referenced_by_webviews.remove(&self.label);
24242424

2425+
// https://github.com/tauri-apps/tauri/issues/14626
2426+
// Because WebKit does not close its network process even when no webviews are running,
2427+
// we need to ensure to re-use the existing process on Linux by keeping the WebContext
2428+
// alive for the lifetime of the app.
2429+
// WebKit on macOS handles this itself.
2430+
#[cfg(not(any(
2431+
target_os = "linux",
2432+
target_os = "dragonfly",
2433+
target_os = "freebsd",
2434+
target_os = "netbsd",
2435+
target_os = "openbsd"
2436+
)))]
24252437
if web_context.referenced_by_webviews.is_empty() {
24262438
context_store.remove(&self.context_key);
24272439
}

0 commit comments

Comments
 (0)