diff --git a/android/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java b/android/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java index 87a6c6f77c..c434247a27 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java +++ b/android/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java @@ -2,6 +2,7 @@ import android.graphics.Bitmap; import android.net.Uri; +import android.webkit.RenderProcessGoneDetail; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; @@ -92,4 +93,19 @@ public void onReceivedHttpError(WebView view, WebResourceRequest request, WebRes view.loadUrl(errorPath); } } + + @Override + public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) { + super.onRenderProcessGone(view, detail); + boolean result = false; + + List webViewListeners = bridge.getWebViewListeners(); + if (webViewListeners != null) { + for (WebViewListener listener : bridge.getWebViewListeners()) { + result = listener.onRenderProcessGone(view, detail) || result; + } + } + + return result; + } } diff --git a/android/capacitor/src/main/java/com/getcapacitor/WebViewListener.java b/android/capacitor/src/main/java/com/getcapacitor/WebViewListener.java index f509e637c4..6df4f6c0ae 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/WebViewListener.java +++ b/android/capacitor/src/main/java/com/getcapacitor/WebViewListener.java @@ -1,5 +1,6 @@ package com.getcapacitor; +import android.webkit.RenderProcessGoneDetail; import android.webkit.WebView; /** @@ -42,4 +43,15 @@ public void onReceivedHttpError(WebView webView) { public void onPageStarted(WebView webView) { // Override me to add behavior to the page started event } + + /** + * Callback for render process gone event. Return true if the state is handled. + * + * @param webView The WebView that loaded + * @return returns false by default if the listener is not overridden and used + */ + public boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail detail) { + // Override me to add behavior to the web view render process gone event + return false; + } }