From: Soren Stoutner Date: Mon, 25 Jan 2021 21:26:27 +0000 (-0700) Subject: Detach WebViews before destroying them in Clean and Exit. https://redmine.stoutner... X-Git-Tag: v3.7~12 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=8e7fcbf6d84cd84ae3fa1fbb65e8be804903a0c3;p=PrivacyBrowserAndroid.git Detach WebViews before destroying them in Clean and Exit. https://redmine.stoutner.com/issues/623 --- diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 4180e28c..c5b8b09f 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -5055,13 +5055,13 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the WebView tab fragment. WebViewTabFragment webViewTabFragment = webViewPagerAdapter.getPageFragment(i); - // Get the fragment view. - View fragmentView = webViewTabFragment.getView(); + // Get the WebView frame layout. + FrameLayout webViewFrameLayout = (FrameLayout) webViewTabFragment.getView(); // Only wipe out the WebView if it exists. - if (fragmentView != null) { + if (webViewFrameLayout != null) { // Get the nested scroll WebView from the tab fragment. - NestedScrollWebView nestedScrollWebView = fragmentView.findViewById(R.id.nestedscroll_webview); + NestedScrollWebView nestedScrollWebView = webViewFrameLayout.findViewById(R.id.nestedscroll_webview); // Clear SSL certificate preferences for this WebView. nestedScrollWebView.clearSslPreferences(); @@ -5069,6 +5069,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Clear the back/forward history for this WebView. nestedScrollWebView.clearHistory(); + // Remove all the views from the frame layout. + webViewFrameLayout.removeAllViews(); + // Destroy the internal state of the WebView. nestedScrollWebView.destroy(); }