I've recently been noticing that a number of users are receiving this IllegalStateException
, which causes a crash of the app. It happens when a WebView
is shown to the user:
Fatal Exception: java.lang.IllegalArgumentException: reasonPhrase can't be empty.
at android.webkit.WebResourceResponse.setStatusCodeAndReasonPhrase + 129(WebResourceResponse.java:129)
at android.webkit.WebResourceResponse.(WebResourceResponse.java:70)
at jY.a + 308(jY.java:308)
at zn.handleMessage + 67(zn.java:67)
at android.os.Handler.dispatchMessage + 102(Handler.java:102)
at android.os.Looper.loop + 211(Looper.java:211)
at android.app.ActivityThread.main + 5373(ActivityThread.java:5373)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke + 372(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1020(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main + 815(ZygoteInit.java:815)
This crash is not happening for every user. I have tried asking users to update Chrome in the hope that it updates Chromium and also asking them to install the latest version of the Android System WebView but neither gave me any success. Has anyone come across this and know how to fix this? I can't even replicate it myself personally.
I also found this bug log here: https://bugs.chromium.org/p/chromium/issues/detail?id=925887
I've also looked at the source code and can see that the relevant crash is being caused by line 154
:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/WebResourceResponse.java
The weird thing is that this supposedly should only happen when an error happens, but I can see that the WebView
correctly loads for the user from screenshots and then the app crashes shortly after. Any help would be greatly appreciated!
I also faced a similar issue when I used Jetpack webkit, from androidx.webkit package.
Using WebViewClientCompat
from androidx.webkit
for creating webViewClient resulted in the above exception,
but falling back to framework's WebViewClient
worked.
webview.webViewClient = WebViewClient()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With