From e7c001e9d648216454964e809651f36fe418470a Mon Sep 17 00:00:00 2001 From: Ralph <24926020+ralphcode@users.noreply.github.com> Date: Thu, 31 Aug 2023 16:09:28 +1000 Subject: [PATCH] Update InAppBrowser.java Fix for webView window not being destroyed correctly causing memory leak (https://github.com/apache/cordova-plugin-inappbrowser/issues/290) --- src/android/InAppBrowser.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 7312cbe..ccc67e6 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -570,6 +570,15 @@ public void onPageFinished(WebView view, String url) { dialog.dismiss(); dialog = null; } + // Fix for webView window not being destroyed correctly causing memory leak + // (https://github.com/apache/cordova-plugin-inappbrowser/issues/290) + if (url.equals("about:blank")) { + inAppWebView.onPause(); + inAppWebView.removeAllViews(); + inAppWebView.destroyDrawingCache(); + inAppWebView.destroy(); + inAppWebView = null; + } } }); // NB: From SDK 19: "If you call methods on WebView from any thread