[
https://issues.apache.org/jira/browse/CB-4586?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13748450#comment-13748450
]
Gilles Bassière edited comment on CB-4586 at 8/23/13 10:52 AM:
---------------------------------------------------------------
I also hit this bug, also trying to use OAuth authentication.
I tried several ways around this bug without much luck:
* With {{executeScript()}}, I received the same warning ("WebView was method
called on thread 'WebViewCoreThread'") in logcat. Tested with this code:
{quote}
var browser = window.open('http://www.google.com', '_blank', 'location=yes');
browser.addEventListener('loadstop', function (event) {
browser.executeScript(\{code: 'window.close();'\});
});
{quote}
* With {{_system}} target, the {{loadstart}}/{{loadstop}} events will not be
triggered.
* I eventually used a real URL for OAuth final redirection. It points to a
simple page asking the user to close the browser, for example:
{quote}
var browser =
window.open('http://depot.natural-solutions.eu/ImageInOsm/auth-final.html',
'_blank', 'location=yes');
{quote}
Note that calling {{window.close();}} in that page did not work,
unfortunately... It did not trigger any warning but the {{.close()}} method is
effective only when pages are opened with a regular {{window.open()}}.
If anyone can advise a better temporary workaround, it would be very nice.
Regards
Gilles
Edit:
some context: My app used to work with PhoneGap 2.5 + ChildBrowser plugin with
OAuth authentication for Flickr services. I'm now trying to migrate to latest
Cordova (I installed 3.0.4). I'm currently testing on Android emulator (API
level 18).
was (Author: gbassiere):
I also hit this bug, also trying to use OAuth authentication.
I tried several ways around this bug without much luck:
* With {{executeScript()}}, I received the same warning ("WebView was method
called on thread 'WebViewCoreThread'") in logcat. Tested with this code:
{quote}
var browser = window.open('http://www.google.com', '_blank', 'location=yes');
browser.addEventListener('loadstop', function (event) {
browser.executeScript(\{code: 'window.close();'\});
});
{quote}
* With {{_system}} target, the {{loadstart}}/{{loadstop}} events will not be
triggered.
* I eventually used a real URL for OAuth final redirection. It points to a
simple page asking the user to close the browser, for example:
{quote}
var browser =
window.open('http://depot.natural-solutions.eu/ImageInOsm/auth-final.html',
'_blank', 'location=yes');
{quote}
Note that calling {{window.close();}} in that page did not work,
unfortunately... It did not trigger any warning but the {{.close()}} method is
effective only when pages are opened with a regular {{window.open()}}.
If anyone can advise a better temporary workaround, it would be very nice.
Regards
Gilles
> Exception when trying to call close() on In-App Browser instance
> ----------------------------------------------------------------
>
> Key: CB-4586
> URL: https://issues.apache.org/jira/browse/CB-4586
> Project: Apache Cordova
> Issue Type: Bug
> Components: Plugin InAppBrowser
> Affects Versions: 3.0.0
> Environment: Tested on Android 4.3 / Nexus 4 and Nexus 10
> Reporter: Victor Costan
> Assignee: Steve Gill
>
> Code sketch:
> {code:javascript}
> var browser = window.open(oauthUrl, '_blank', 'location=yes');
> browser.addEventListener('loadstop', function() {
> if (/* event.url matches the OAuth response URL*/ true) {
> browser.close();
> }
> });
> {code}
> Stack trace from adb logcat.
> {code}
> W/webview_proxy(27421): java.lang.Throwable: Warning: A WebView method was
> called on thread 'WebViewCoreThread'. All WebView methods must be called on
> the UI thread. Future versions of WebView may not support use on other
> threads.
> W/webview_proxy(27421): at
> android.webkit.WebView.checkThread(WebView.java:1918)
> W/webview_proxy(27421): at
> android.webkit.WebView.loadUrl(WebView.java:771)
> W/webview_proxy(27421): at
> org.apache.cordova.core.InAppBrowser.closeDialog(InAppBrowser.java:316)
> W/webview_proxy(27421): at
> org.apache.cordova.core.InAppBrowser.execute(InAppBrowser.java:161)
> W/webview_proxy(27421): at
> org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:65)
> W/webview_proxy(27421): at
> org.apache.cordova.PluginManager.execHelper(PluginManager.java:229)
> W/webview_proxy(27421): at
> org.apache.cordova.PluginManager.exec(PluginManager.java:214)
> W/webview_proxy(27421): at
> org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
> W/webview_proxy(27421): at
> android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
> W/webview_proxy(27421): at
> android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
> W/webview_proxy(27421): at
> android.webkit.JWebCoreJavaBridge.fireSharedTimer(JWebCoreJavaBridge.java:92)
> W/webview_proxy(27421): at
> android.webkit.JWebCoreJavaBridge.handleMessage(JWebCoreJavaBridge.java:108)
> W/webview_proxy(27421): at
> android.os.Handler.dispatchMessage(Handler.java:99)
> W/webview_proxy(27421): at android.os.Looper.loop(Looper.java:137)
> W/webview_proxy(27421): at
> android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:814)
> W/webview_proxy(27421): at java.lang.Thread.run(Thread.java:841)
> W/System.err(27421): java.lang.RuntimeException: java.lang.Throwable:
> Warning: A WebView method was called on thread 'WebViewCoreThread'. All
> WebView methods must be called on the UI thread. Future versions of WebView
> may not support use on other threads.
> W/System.err(27421): at android.webkit.WebView.checkThread(WebView.java:1927)
> W/System.err(27421): at android.webkit.WebView.loadUrl(WebView.java:771)
> W/System.err(27421): at
> org.apache.cordova.core.InAppBrowser.closeDialog(InAppBrowser.java:316)
> W/System.err(27421): at
> org.apache.cordova.core.InAppBrowser.execute(InAppBrowser.java:161)
> W/System.err(27421): at
> org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:65)
> W/System.err(27421): at
> org.apache.cordova.PluginManager.execHelper(PluginManager.java:229)
> W/System.err(27421): at
> org.apache.cordova.PluginManager.exec(PluginManager.java:214)
> W/System.err(27421): at
> org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
> W/System.err(27421): at
> android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
> W/System.err(27421): at
> android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
> W/System.err(27421): at
> android.webkit.JWebCoreJavaBridge.fireSharedTimer(JWebCoreJavaBridge.java:92)
> W/System.err(27421): at
> android.webkit.JWebCoreJavaBridge.handleMessage(JWebCoreJavaBridge.java:108)
> W/System.err(27421): at android.os.Handler.dispatchMessage(Handler.java:99)
> W/System.err(27421): at android.os.Looper.loop(Looper.java:137)
> W/System.err(27421): at
> android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:814)
> W/System.err(27421): at java.lang.Thread.run(Thread.java:841)
> W/System.err(27421): Caused by: java.lang.Throwable: Warning: A WebView
> method was called on thread 'WebViewCoreThread'. All WebView methods must be
> called on the UI thread. Future versions of WebView may not support use on
> other threads.
> W/System.err(27421): at android.webkit.WebView.checkThread(WebView.java:1918)
> W/System.err(27421): ... 15 more
> D/dalvikvm(27421): GC_CONCURRENT freed 410K, 5% free 9371K/9808K, paused
> 2ms+4ms, total 22ms
> W/CordovaPlugin(27421): Attempted to send a second callback for ID:
> InAppBrowser1475593509
> W/CordovaPlugin(27421): Result was:
> {"type":"loadstart","url":"http:\/\/about:blank"}
> W/CordovaPlugin(27421): Attempted to send a second callback for ID:
> InAppBrowser1475593509
> W/CordovaPlugin(27421): Result was: {"type":"exit"}
> W/CordovaPlugin(27421): Attempted to send a second callback for ID:
> InAppBrowser1475593509
> W/CordovaPlugin(27421): Result was: {"type":"loadstop","url":"about:blank"}
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira