Cristian Totolici created CB-14179:
--------------------------------------
Summary: Cordova is not initialized properly when using Android
System Webview v67
Key: CB-14179
URL: https://issues.apache.org/jira/browse/CB-14179
Project: Apache Cordova
Issue Type: Bug
Components: cordova-android
Affects Versions: cordova-android-7.0.0
Environment: WebView: This only happens on the AndroidSystemWebView
implementation (not Chrome) versions 67.0.3396.*
Android OS: All versions on which the above WebView is compatible so I think
[5, 6.0.1]
Device: Nexus 5, Nexus 5x, HTC One M9
Reporter: Cristian Totolici
Attachments: MainActivity.java, cordova.log
Cordova not initialized properly:
{noformat}
06-28 10:52:14.774 12625-12625/com.example.hello E/CordovaBridge: gap_init
called from restricted origin:
{noformat}
I have looked into this issue and it seems that sometimes the origin URL is
empty and that is the reason why the message above is shown.
{code:java}
@Override
public boolean onJsPrompt(WebView view, String origin, String message,
String defaultValue, final JsPromptResult result) {
Log.d(LOG_TAG, (tries++) +" onJsPrompt: "+origin);
// Unlike the @JavascriptInterface bridge, this method is always called
on the UI thread.
String handledRet = parentEngine.bridge.promptOnJsPrompt(origin,
message, defaultValue);
if (handledRet != null) {
result.confirm(handledRet);
} else {
dialogsHelper.showPrompt(message, defaultValue, new
CordovaDialogsHelper.Result() {
@Override
public void gotResult(boolean success, String value) {
if (success) {
result.confirm(value);
} else {
result.cancel();
}
}
});
}
return true;
}
{code}
The strange think is that if you call view.getUrl() the url is return
correctly. I was wondering, can be that used instead of the origin url ?
This is an issue not that easy to reproduce, I managed to reproduce with a
simple hello world cordova app.
I dis some tweaks to increase the occurrence of the issue:
1. Enable "Don't keep activities" from the developer options
2. Using "Recents" button open and close the app very fast
3. I have attached the MainActvity.java that I used. There is some commented
code that can be uncommented to increase the occurrence rate of the issue.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]