fix: handle webview provider missing exception#34456
fix: handle webview provider missing exception#34456rachitmishra wants to merge 5 commits intofacebook:mainfrom
Conversation
Base commit: 2fc44ac |
| } else { | ||
| throw exception; | ||
| } | ||
| // fatal exception is no good for the user experience, |
There was a problem hiding this comment.
I'm generally against this change as we would blindly catch all the exceptions and return null here while we want to distinguish between MissingWebViewPackageException and other type of exceptions
There was a problem hiding this comment.
@cortinico i totally agree. this is not a best practice, or in principal good code.
Although the thought here is that, for any case when the CookieManager instance is not available, returning a null is better than the fatal exception.
|
I opened #34483 but IMHO this is better. It's very weird to me that not having a webview at all is fine but having one that can't be loaded for whatever reason is a fatal crash |
Base commit: 2fc44ac |
I've looked again at this PR and I believe we should merge it as the scope is limited to only the CookieManager. @rachitmishra Can you update the comment before the |
|
@cortinico I have updated the comment and our reasoning, let me know if we can improve this more :) |
ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java
Outdated
Show resolved
Hide resolved
…ForwardingCookieHandler.java Co-authored-by: Nicola Corti <corti.nico@gmail.com>
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
This pull request was successfully merged by @rachitmishra in 3f3394a. When will my fix make it into a release? | Upcoming Releases |
Summary
The existing fix to handle missing WebView provider uses string comparison based checks to handle the exception gracefully, or otherwise simply throw the exception. This ends up crashing the app for the end user.
Fatal exceptions are bad in any case and not good user experience, we can gracefully handle this by returning
nullfor all cases when WebView provider is not found.Changelog
[Android] [Fixed] - Gracefully handle crash if no WebView provider is found on the device
Test Plan
IMO no testing is required as we were already returning null in certain cases after handling the exception message, also
ForwardingCookieManager::getCookieManageris already marked@Nullableso we are safe there.