From d40cb0e1b0fb233a27b9d476167814d2853acf2a Mon Sep 17 00:00:00 2001 From: Rodolfo Date: Thu, 9 Sep 2021 15:22:46 -0700 Subject: [PATCH] Fix missing webview provider crash on Android (#32165) Summary: I applied the changes requested in this PR: https://github.com/facebook/react-native/pull/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 https://github.com/facebook/react-native/pull/24533 but https://github.com/facebook/react-native/pull/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 https://github.com/facebook/react-native/pull/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 Pull Request resolved: https://github.com/facebook/react-native/pull/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 --- .../react/modules/network/ForwardingCookieHandler.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java index 63a9fe7ab5a29e..529af0090f5388 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java @@ -144,10 +144,7 @@ protected void doInBackgroundGuarded(Void... params) { // specific exception. // 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")) { + && exception.getClass().getCanonicalName().contains("MissingWebViewPackageException")) { return null; } else { throw exception;