balazsgerlei / SecureWebView

Android WebView wrapper with secure defaults to avoid security issues caused by misconfiguring WebViews.
Creative Commons Zero v1.0 Universal
3 stars 2 forks source link

🐞 Crash in shouldBlockRequest caused by WebView method called not from the Main Thread #11

Closed marazmarci closed 2 months ago

marazmarci commented 3 months ago

If you try to run the Breakout or the Opaque Origin demos with the Secure WebView toggle enabled, the app crashes with the following stack trace:

FATAL EXCEPTION: main
Process: dev.gerlot.securewebview.sample, PID: 10468
java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'ThreadPoolForeg'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 2) {e57dea9} called on null, FYI main Looper is Looper (main, tid 2) {e57dea9})
    at android.webkit.WebView.checkThread(WebView.java:2627)
    at android.webkit.WebView.getSettings(WebView.java:1994)
    at dev.gerlot.securewebview.SecureWebView.shouldBlockRequest(SecureWebView.java:202)
    at dev.gerlot.securewebview.SecureWebView.-$$Nest$mshouldBlockRequest(Unknown Source:0)
    at dev.gerlot.securewebview.SecureWebView$SecureWebViewClient.shouldInterceptRequest(SecureWebView.java:138)
    at WV.J5.a(chromium-TrichromeWebViewGoogle6432.aab-stable-631211833:86)
    at org.chromium.android_webview.AwContentsBackgroundThreadClient.shouldInterceptRequestFromNative(chromium-TrichromeWebViewGoogle6432.aab-stable-631211833:15)
Caused by: java.lang.Throwable: A WebView method was called on thread 'ThreadPoolForeg'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 2) {e57dea9} called on null, FYI main Looper is Looper (main, tid 2) {e57dea9})
    at android.webkit.WebView.checkThread(WebView.java:2622)
    at android.webkit.WebView.getSettings(WebView.java:1994) 
    at dev.gerlot.securewebview.SecureWebView.shouldBlockRequest(SecureWebView.java:202) 
    at dev.gerlot.securewebview.SecureWebView.-$$Nest$mshouldBlockRequest(Unknown Source:0) 
    at dev.gerlot.securewebview.SecureWebView$SecureWebViewClient.shouldInterceptRequest(SecureWebView.java:138) 
    at WV.J5.a(chromium-TrichromeWebViewGoogle6432.aab-stable-631211833:86) 
    at org.chromium.android_webview.AwContentsBackgroundThreadClient.shouldInterceptRequestFromNative(chromium-TrichromeWebViewGoogle6432.aab-stable-631211833:15)