Description
webview.evalJS returns error in case of android while it works fine for iOS.
It is used to call returnSomething() in webview which in turn return some text. for android it returns null with below warning :
[WARN] : TiWebViewBinding: (KrollRuntimeThread) [1644,95408] Timeout waiting to evaluate JS
Test Case
app.js
var win = Titanium.UI.createWindow({
backgroundColor : '#fff'
});
var button = Ti.UI.createButton({
title: "Do something",
top: 10
});
button.addEventListener("click", function() {
Ti.API.info("button click");
var something = webview.evalJS("returnSomething()");
alert("Button click returned " + something);
});
win.add(button);
var webview = Titanium.UI.createWebView({
top: 100,
url: '/test.html'
});
win.add(webview);
win.open();
test.html
<html>
<body>
I am in test.html
<script>
function returnSomething() {
alert("about to return something")
return "something returned from test.html";
}
</script>
</body>
</html>
Expected output
Clicking the button labeled "Do something" should alert
"Button click returned something returned from test.html"
Actual output
iOS:
It works fine.
Android:
[WARN] : TiWebViewBinding: (KrollRuntimeThread) [1644,95408] Timeout waiting to evaluate JS
Note : Its reproducible for android 4.3 only
I tried this on Titanium SDK 3.2.0.GA: Nexus 7 (4.3) Nexus 5 (4.4) Samsung SII (2.3) I was unable to reproduce the issue. I always get the "Button click returned something returned from test.html" alert dialog.
Hi, This issue is reproducible on android 4.3 version. I tested it on samsung galaxy s3. Regards, Rupesh
Rupesh, I have these errors as well. Against which Android API are you building?
Unable to reproduce this issue, tested with the following environment; Pixel (7.1) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.2 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80