Skip to content

Commit c4b51a4

Browse files
Alessandro BassoAlessandro Basso
Alessandro Basso
authored and
Alessandro Basso
committed
Android - Fix for webView window not being destroyed correctly causing memory leak (apache#290)
1 parent 171c553 commit c4b51a4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: src/android/InAppBrowser.java

+10
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,16 @@ public void onPageFinished(WebView view, String url) {
541541
dialog.dismiss();
542542
dialog = null;
543543
}
544+
545+
// Fix for webView window not being destroyed correctly causing memory leak
546+
// (https://github.com/apache/cordova-plugin-inappbrowser/issues/290)
547+
if (url.equals(new String("about:blank"))) {
548+
inAppWebView.onPause();
549+
inAppWebView.removeAllViews();
550+
inAppWebView.destroyDrawingCache();
551+
inAppWebView.destroy();
552+
inAppWebView = null;
553+
}
544554
}
545555
});
546556
// NB: From SDK 19: "If you call methods on WebView from any thread

0 commit comments

Comments
 (0)