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

Added check to handle all cases of MissingWebViewPackageException #26189

Closed
wants to merge 6 commits into from

Conversation

siddhantsoni
Copy link
Contributor

@siddhantsoni siddhantsoni commented Aug 26, 2019

Summary

We have been experiencing the below crashes in our Flipkart Android app:

image
image

Stack overflow thread for the issue that is causing this crash: https://stackoverflow.com/a/56246743

The change I have done is an enhancement on the following PR which got merged to master: #24533

The exception handling for this crash already exists but it relies on having a specific string in the error message ("Webview not installed"). But the error message for the crashes above does not include this string.

I have added a check for all the crashes involving the MissingWebViewPackageException.
Refer the file: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/WebViewFactory.java#102

Changelog

[ANDROID] [Fixed] - The ReactCookieJarContainer/ForwardingCookieHandler now handles all the cases of missing WebView exceptions gracefully.

Test Plan

No new tests have been added.
CI should pass.

This fix was made based on the exception stacktrace. I have not spent the time to acquire one of the devices that it is happening on.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 26, 2019
@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Aug 26, 2019
@siddhantsoni siddhantsoni changed the title Added check for web view package in error message to handle the exception. Added check for web view package in error message to handle the exception Aug 26, 2019
@siddhantsoni siddhantsoni reopened this Aug 27, 2019
@siddhantsoni
Copy link
Contributor Author

@thorbenprimke and @cpojer please take a look at this PR whenever possible :)

@siddhantsoni siddhantsoni changed the title Added check for web view package in error message to handle the exception Added check to handle all cases of MissingWebViewPackageException Aug 27, 2019
@react-native-bot react-native-bot added the Component: WebView Related to the WebView component. label Aug 27, 2019
@siddhantsoni
Copy link
Contributor Author

@hramos can you please review or assign someone to review this change. Thanks!

// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/WebViewFactory.java#98
if (message != null && message.contains("No WebView installed")) {
// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/WebViewFactory.java#348
if (message != null && (exception.getClass().getCanonicalName().equals("android.webkit.WebViewFactory.MissingWebViewPackageException")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you actually check this code and whether it works? The code here has a syntax error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer Sorry for the syntax error. I had actually tested this code in our internal fork. Made this mistake while committing here. Fixing this.

Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@cpojer
Copy link
Contributor

cpojer commented Sep 11, 2019

Yap that's what I thought ;)

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@siddhantsoni
Copy link
Contributor Author

@cpojer @hramos I have resolved the linter issue. Please merge this change whenever possible. Thanks!

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @siddhantsoni in 314eba9.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Sep 11, 2019
@siddhantsoni
Copy link
Contributor Author

@cpojer Thanks for quick merge! :)

facebook-github-bot pushed a commit that referenced this pull request Sep 9, 2021
Summary:
I applied the changes requested in this PR: #29089

We upgraded to RN 0.62.2 on our latest release and started to see again the "Failed to load WebView provider: No WebView installed" (see below for Crashlytics screenshot)

![image](https://user-images.githubusercontent.com/870365/131935283-033fbd44-5a3b-49b0-bd25-3d6733f22040.png)

This crash had been fixed by #24533 but #26189 (added in 0.62) reverted the fix

Indeed the exception raised in Crashlytics is actually a `AndroidRuntimeException` and `MissingWebViewPackageException` is only part of the message.

For instance, in the screenshot above, the exception message is `android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed`

Now these crashes are quite tricky to reproduce, so to be on the safe side, I'm filtering out all exceptions containing `WebView` as suggested by thorbenprimke on the original fix.

If my reasoning is correct, it should fix siddhantsoni 's issue as well, since `WebView` is included in `MissingWebViewPackageException`
But following that reasoning, I am not sure #26189 fixed siddhantsoni 's issue, so siddhantsoni if you could check that this PR also fixes your issue, that would be great!

## Changelog

[Android] [Fixed] - Fix missing WebView provider crash in ForwardingCookieHandler

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

Pull Request resolved: #32165

Test Plan:
I created a version of react native with this patch applied

```
"react-native": "almouro/react-native#release/062-2-fix-missing-webview-provider"
```

Before the fix ~0.1% of our users were impacted on Android, no new crashes have occurred after the update.

This is putting back what was already in place and working for us, but making the check wider to catch more errors.

Reviewed By: lunaleaps

Differential Revision: D30847404

Pulled By: sota000

fbshipit-source-id: fe3b5fa2c9ebde5bedd17a9d6394a52ccdbdf0d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: WebView Related to the WebView component. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants