|
31 | 31 | import android.os.Build; |
32 | 32 | import android.view.View; |
33 | 33 | import android.webkit.HttpAuthHandler; |
| 34 | +import android.webkit.RenderProcessGoneDetail; |
34 | 35 | import android.webkit.SslErrorHandler; |
35 | 36 | import android.webkit.WebResourceError; |
36 | 37 | import android.webkit.WebResourceRequest; |
@@ -218,6 +219,26 @@ public void onPageFinished(final WebView view, |
218 | 219 | view.setVisibility(View.VISIBLE); |
219 | 220 | } |
220 | 221 |
|
| 222 | + /** |
| 223 | + * Handles WebView render process crashes or terminations. Previously, a WebView render process crash could cause |
| 224 | + * the calling application to crash as well, because the Broker was not handling the crash and packaging it into an exception. |
| 225 | + * |
| 226 | + * Overriding this method allows us to gracefully handle WebView render process crashes by sending an error to the callback object |
| 227 | + * when the render process is gone, preventing the application from crashing. |
| 228 | + * @param view webview in question |
| 229 | + * @param detail minor details about the render process being lost |
| 230 | + * @return whether or not we handled the crash |
| 231 | + */ |
| 232 | + @Override |
| 233 | + @RequiresApi(api = Build.VERSION_CODES.O) |
| 234 | + public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) { |
| 235 | + // Handle render process crash |
| 236 | + // TODO: This should probably have a more specific error code, but we'll need to ask OneAuth to add new handling for it. |
| 237 | + sendErrorToCallback(view, ERROR_UNKNOWN, "WebView render process gone, crashed? : " + detail.didCrash()); |
| 238 | + |
| 239 | + return true; // Indicate we handled the crash |
| 240 | + } |
| 241 | + |
221 | 242 | @Override |
222 | 243 | public void onPageStarted(final WebView view, |
223 | 244 | final String url, |
|
0 commit comments