Skip to content
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

Closed

Conversation

peitschie
Copy link

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)

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)
@peitschie
Copy link
Author

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 Capacitor.Plugins.ChromeCrasher.loadChromeUrl()

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;
Copy link
Author

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);
Copy link
Author

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).

@markemer
Copy link
Member

I like this idea, I'll have to see what the team thinks.

@jcesarmobile
Copy link
Member

closing in favor of #6946

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants