-
Notifications
You must be signed in to change notification settings - Fork 46
Add onRenderProcessGone override to webview logic, Fixes AB#3405900 #2788
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
base: dev
Are you sure you want to change the base?
Conversation
✅ Work item link check complete. Description contains link AB#3405900 to an Azure Boards work item. |
❌ Work item link check failed. Description contains AB#3405900 but the Bot could not link it to an Azure Boards work item. Click here to learn more. |
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.
Pull Request Overview
This PR adds error handling for WebView render process crashes to prevent ANRs in calling applications. When the WebView render process fails, the new onRenderProcessGone
override catches the crash and sends an error to the callback instead of letting the exception propagate uncaught.
- Overrides
onRenderProcessGone
method to handle WebView process crashes gracefully - Implements version-specific error messages based on Android SDK level
- Returns true to indicate the crash was handled successfully
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
// Handle render process crash | ||
// TODO: is there an errorCode that makes more sense in this spot? We aren't actually getting anything back from webView, we have to come up with it ourselves | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
sendErrorToCallback(view, 0, "WebView render process gone, crahsd? : " + detail.didCrash()); |
Copilot
AI
Oct 18, 2025
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.
Corrected spelling of 'crahsd' to 'crashed'.
sendErrorToCallback(view, 0, "WebView render process gone, crahsd? : " + detail.didCrash()); | |
sendErrorToCallback(view, 0, "WebView render process gone, crashed? : " + detail.didCrash()); |
Copilot uses AI. Check for mistakes.
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.
Agreed with CP her on spelling error to be updated.
common/src/main/java/com/microsoft/identity/common/internal/ui/webview/OAuth2WebViewClient.java
Show resolved
Hide resolved
// Handle render process crash | ||
// TODO: is there an errorCode that makes more sense in this spot? We aren't actually getting anything back from webView, we have to come up with it ourselves | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
sendErrorToCallback(view, 0, "WebView render process gone, crahsd? : " + detail.didCrash()); |
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.
Agreed with CP her on spelling error to be updated.
@Override | ||
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) { | ||
// Handle render process crash | ||
// TODO: is there an errorCode that makes more sense in this spot? We aren't actually getting anything back from webView, we have to come up with it ourselves |
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.
Is the plan to leave TODO here in comment?
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.
Nope, i usually add it to prompt discussion in PR stage, then remove it once we decide. Sometimes it stays if the discussion is not finalized but code can go in for the time.
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.
Maybe one could be created in ClientException for Webview crashes (WEBVIEW_CRASH?) which we can let oneauth know about.
@Override | ||
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) { | ||
// Handle render process crash | ||
// TODO: is there an errorCode that makes more sense in this spot? We aren't actually getting anything back from webView, we have to come up with it ourselves |
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.
Maybe one could be created in ClientException for Webview crashes (WEBVIEW_CRASH?) which we can let oneauth know about.
We do not gracefully handle webview process crashes, which can cause ANRs for calling activitties (LTW bug: https://dev.azure.com/microsoft/OS/_workitems/edit/59756442). In this PR we override the webview method onRenderProcessGone to handle what to do if webview no longer is able to render content, where we send the error to the callback rather than having an uncaught exception.
AB#3405900