From b26cb67a5322b768db5ebcc813e86ee2dabd74b5 Mon Sep 17 00:00:00 2001 From: Dimitris Dafnis <68849116+jim-daf@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:11:42 +0200 Subject: [PATCH 1/2] feat(webview): add release() helper for clean teardown Refs #562 --- .../src/main/java/com/ferg/awfulapp/webview/AwfulWebView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Awful.apk/src/main/java/com/ferg/awfulapp/webview/AwfulWebView.java b/Awful.apk/src/main/java/com/ferg/awfulapp/webview/AwfulWebView.java index eddc3b230..2148428bf 100644 --- a/Awful.apk/src/main/java/com/ferg/awfulapp/webview/AwfulWebView.java +++ b/Awful.apk/src/main/java/com/ferg/awfulapp/webview/AwfulWebView.java @@ -2,6 +2,7 @@ import android.content.Context; import android.graphics.Color; +import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import android.util.AttributeSet; From 1cead65b0693379e195b990085467dc3faf8e567 Mon Sep 17 00:00:00 2001 From: Dimitris Dafnis <68849116+jim-daf@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:11:44 +0200 Subject: [PATCH 2/2] feat(webview): add release() helper for clean teardown Refs #562 --- .../ferg/awfulapp/webview/AwfulWebView.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Awful.apk/src/main/java/com/ferg/awfulapp/webview/AwfulWebView.java b/Awful.apk/src/main/java/com/ferg/awfulapp/webview/AwfulWebView.java index 2148428bf..a4418de89 100644 --- a/Awful.apk/src/main/java/com/ferg/awfulapp/webview/AwfulWebView.java +++ b/Awful.apk/src/main/java/com/ferg/awfulapp/webview/AwfulWebView.java @@ -2,7 +2,6 @@ import android.content.Context; import android.graphics.Color; -import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import android.util.AttributeSet; @@ -117,6 +116,28 @@ public void onResume() { resumeTimers(); } + + /** + * Issue #562: the renderer process leaks when a WebView is dropped + * without an explicit destroy(), and the well-known fix is to + * detach from the parent first so Chromium can release its surface. + * Callers (fragments, activities) should invoke this from their + * own onDestroy() / onDestroyView(). + */ + public void release() { + if (jsInterface != null) { + removeJavascriptInterface(HANDLER_NAME_IN_JAVASCRIPT); + jsInterface = null; + } + loadUrl("about:blank"); + clearHistory(); + ViewGroup parent = (ViewGroup) getParent(); + if (parent != null) { + parent.removeView(this); + } + destroy(); + } + /** * Connects a handler to the JavaScript functions added to HTML for threads, posts, messages etc. *