Skip to content

Commit

Permalink
fix: Crash if WebView is disabled (#34483)
Browse files Browse the repository at this point in the history
Summary:
When the webview is updated by play store, all apps that has loaded webview gets killed. For background see https://issuetracker.google.com/issues/228611949?pli=1

We have a long-running app and don't want this to happen and while we are not using webview anywhere, we are using websockets that loads it for reading cookies, however we are not using cookies to authenticate the websocket and thus want to disable the webview to avoid loading it unnecessarily and then getting killed unnecessarily.

The webview has support for beeing disabled https://developer.android.com/reference/android/webkit/WebView#disableWebView() however as-is this crashes React Native. It seems to me like this case is very similar to not having web view installed and should be handled in the same way.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Avoid crash in ForwardingCookieHandler if webview is disabled

Pull Request resolved: #34483

Test Plan: Add `WebView.disableWebView();` as the first line in `MainActivity.onCreate`.

Reviewed By: christophpurrer

Differential Revision: D38981827

Pulled By: cipolleschi

fbshipit-source-id: 335a8420568ad0c80b834ae8a3b164e55ebe26f3
  • Loading branch information
Pajn authored and facebook-github-bot committed Aug 30, 2022
1 parent 4f486c7 commit 5451cd4
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ protected void doInBackgroundGuarded(Void... params) {
|| (message != null
&& (message.contains("WebView provider")
|| message.contains("No WebView installed")
|| message.contains("Cannot load WebView")))) {
|| message.contains("Cannot load WebView")
|| message.contains("disableWebView")
|| message.contains("WebView is disabled")))) {
return null;
} else {
throw exception;
Expand Down

2 comments on commit 5451cd4

@billnbell
Copy link
Contributor

Choose a reason for hiding this comment

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

I ge this 100x times on 0.70

@cortinico
Copy link
Contributor

Choose a reason for hiding this comment

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

I ge this 100x times on 0.70

This hasn't been released yet. Will land in 0.71

Please sign in to comment.