-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(android): add plugin hooks for WebViewClient.onRenderProcessGone #6416
Conversation
1881b8e
to
fb6fcb4
Compare
This change allows more advanced handling of the webview render process termination. This can be useful for capturing additional information, or even conceivably allow the crash to be prevented should a plugin choose to. Source: https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail)
fb6fcb4
to
1967517
Compare
The main reason for wanting a plugin hook like this is to feed app crashes into Crashalytics/AppCenter/etc. The normal crash reporters do not detect or report on the chrome renderer being terminated, meaning most app crashes are lost unless they happen to be in a native thread or call somewhere. This feature has now been accepted into cordova-android: apache/cordova-android#1574 I've created a plugin to simplify crashing the chrome renderer: https://github.com/peitschie/capacitor-chrome-crasher (capacitor 5 compatible) Once that plugin is added to an app, it's as simple as Would love an indication about whether this is something CapacitorJS would want, as so far there's been no feedback from any maintainers 😅 |
Plugin plugin = entry.getValue().getInstance(); | ||
if (plugin != null) { | ||
if (plugin.onRenderProcessGone(view, detail)) { | ||
result = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop continues irrespective of the return value so that any reporting plugins can find out about the crash even if one of the plugins is attempting to handle it gracefully.
|
||
@Override | ||
public boolean onRenderProcessGone(final WebView view, RenderProcessGoneDetail detail) { | ||
return bridge.onRenderProcessGone(view, detail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The webview is passed down as the onRenderProcessGone
method is called for any render crashes within the app (including a pop-up tab, for example).
I like this idea, I'll have to see what the team thinks. |
closing in favor of #6946 |
This change allows more advanced handling of the webview render process termination. This can be useful for capturing additional information, or even conceivably allow the crash to be prevented should a plugin choose to.
Source:
https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail)