braintree / popup-bridge-android

PopupBridge allows WebViews to open popup windows in a browser and send data back to the WebView
MIT License
53 stars 27 forks source link

Error: A WebView method was called on thread 'JavaBridge'. #10

Closed AndreRoss closed 6 years ago

AndreRoss commented 7 years ago

General information

The method 'open(String url)' is called in WebviewInterface. The url is https://www.paypal.com/checkoutnow?..&useraction=commit and i get an exception in my webview.

The webview is shown inside a fragment.

java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {5891226} called on Looper (JavaBridge, tid 621) {a07812e}, FYI main Looper is Looper (main, tid 1) {5891226}) at android.webkit.WebView.checkThread(WebView.java:2334) at android.webkit.WebView.evaluateJavascript(WebView.java:1036) at com.braintreepayments.popupbridge.PopupBridge.onBrowserSwitchResult(PopupBridge.java:132) at com.braintreepayments.browserswitch.BrowserSwitchFragment.browserSwitch(BrowserSwitchFragment.java:132) at com.braintreepayments.browserswitch.BrowserSwitchFragment.browserSwitch(BrowserSwitchFragment.java:107) at com.braintreepayments.popupbridge.PopupBridge.open(PopupBridge.java:148)

crookedneighbor commented 6 years ago

It looks like JavaScript evaluation is not always happening on the correct thread and needs to be wrapped in a Looper/Handler.

We'll make this fix unless you'd like to submit a PR for it.