Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16150] Android: WebView evalJS causes error

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-01-13T21:42:19.000+0000
Affected Version/sRelease 3.2.0
Fix Version/s2014 Sprint 01, 2014 Sprint 01 Core, Release 3.3.0
ComponentsAndroid
LabelssupportTeam, triage
ReporterRupesh Sharma
AssigneeAllen Yeung
Created2014-01-08T12:38:47.000+0000
Updated2017-03-31T21:53:25.000+0000

Description

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

Comments

  1. Allen Yeung 2014-01-13

    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.
  2. Rupesh Sharma 2014-01-16

    Hi, This issue is reproducible on android 4.3 version. I tested it on samsung galaxy s3. Regards, Rupesh
  3. Timan Rebel 2014-01-28

    Rupesh, I have these errors as well. Against which Android API are you building?
  4. Lee Morris 2017-03-31

    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

JSON Source