{ "id": "64186", "key": "TIMOB-3554", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11357", "description": "Mobile 1.8.0 M04", "name": "Sprint 2011-25", "archived": true, "released": true, "releaseDate": "2011-06-27" } ], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2011-07-07T11:12:08.000+0000", "created": "2011-04-15T03:46:35.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [], "versions": [ { "id": "11260", "description": "", "name": "Release 1.6.2", "archived": true, "released": true, "releaseDate": "2011-04-20" } ], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-02-15T10:14:17.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "A number of users in the Q&A have reported that evalJS applied to a webview causes an exception. The following usecase demonstrates the problem, which results in [this trace|http://pastebin.com/raw.php?i=HNGHQn6C]\r\n\r\n{code:title=app.js}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : \"blue\",\r\n\texitOnClose:true\r\n});\r\n\r\nvar myWeb = Ti.UI.createWebView({\r\n\turl:'myweb.htm',\r\n\t// url:'http://www.mydomain.net/myweb.htm',\r\n\turl:'myweb.htm',\r\n\tbackgroundColor:'green'\r\n});\r\n\r\nmyWeb.addEventListener('load',function(e){\r\n\tvar title = myWeb.evalJS(\"return document.title;\");\r\n\tTi.API.info(\"The title of the webview is \" + title);\r\n});\r\n\r\nwin.add(myWeb);\r\n\r\nwin.open();\r\n{code}\r\n\r\n{code:title=myapp.htm}\r\n\r\n\r\n\r\n\r\nThis is Titanium\r\n\r\n\r\n
\r\n\t

Testing Titanium

\r\n\t
\r\n\r\n\t

\r\n\t\tThis is a Titanium test.\r\n\t

\r\n\t
\r\n
\r\n\r\n\r\n{code}\r\n\r\n", "attachment": [], "flagged": false, "summary": "webview.evalJS() causes exception", "creator": { "name": "hal", "key": "hal", "displayName": "hal", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "environment": "* Titanium 1.7.1 (2011/06/17 00:13 293a6d...)\r\n* Android 2.2 emulator (crash)\r\n", "comment": { "comments": [ { "id": "130753", "author": { "name": "hal", "key": "hal", "displayName": "hal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Moving contents of ticket #3510, by user KT, here:

\n

Here's a test that will crash on Android 2.2 / Ti 1.7.X with\nSIGSEGV:

\n
\nvar win = Ti.UI.createWindow({\n    // Android\n    navBarHidden: false,\n    exitOnClose: true\n});\nvar view = Ti.UI.createWebView({\n    scalesPageToFit: false,\n    url: 'something.html'\n});\nview.addEventListener('load', function() {\n    view.evalJS(\"test\");\n});\nwin.add(view);\nwin.open();\n
\n

This code gives a crash dump similar to http://pastie.org/1754641

\n

Just as some further background, and to help try to pinpoint it\nregression-wise, users seem to be having similar issues for at\nleast a year:

\n\n

This is, strangely, in direct contravention to the \ndrillbit test

\n

If that works, then what is drillbit doing differently so that\nit works whereas the app.js above crashes immediately?

\n

This crash doesn't seem to happen on 3.0. But the necessary Ti\nJavascript seems to never get injected, as is the case with 1.6\n(i.e., no crash, but no Ti injection). The injection problem is\ndescribed separately in #3539

{html}", "updateAuthor": { "name": "hal", "key": "hal", "displayName": "hal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:46:36.000+0000", "updated": "2011-04-15T03:46:36.000+0000" }, { "id": "157088", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "The problem was with the code that the user was passing to evalJS(), ie:\n{code}myWeb.evalJS(\"return document.title;\"){code}\n\nThe test code above works as expected, and returns the following output:\n\n{code}\n 53 ActivityManager I Displayed activity com.testing.testing7/.Testing7Activity: 3335 ms (total 3335 ms)\n 53 gralloc E [unregister] handle 0x3e2b20 still locked (state=40000001)\n 1493 TiWebViewBinding D (main) [1271,1300] getJSValue:javascript:_TiReturn.setValue((function(){try{return document.title+\"\";}catch(ti_eval_err){return '';}})());\n 1493 TiAPI I (kroll$1: app://app.js) [70,1370] ************TITLE: This is Titanium\n 1493 TiWebViewBinding D (main) [129,1499] getJSValue:javascript:_TiReturn.setValue((function(){try{return document.getElementById(\"inner-content\").getElementsByTagName(\"p\").item(0).innerHTML+\"\";}\n catch(ti_eval_err){return '';}})());\n 1493 TiAPI I (kroll$1: app://app.js) [25,1524] ************CONTENT: This is a Titanium test\n{code}", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-06-18T14:55:29.000+0000", "updated": "2011-06-18T14:55:29.000+0000" }, { "id": "157089", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "This is the code that proves that this issue is either invalid or fixed, as it works as expected:\r\n\r\n\r\n{code:title=app.js}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : \"blue\",\r\n\texitOnClose:true\r\n});\r\n\r\nvar view = Ti.UI.createWebView({\r\n\tscalesPageToFit: false,\r\n\t// url:'http://www.mydomain.net/myweb.htm'\r\n\turl:'myweb.htm'\r\n});\r\nview.addEventListener('load', function() {\r\n\tTi.API.info(\"************TITLE: \" + view.evalJS(\"document.title\"));\r\n\tTi.API.info(\"************CONTENT: \" + view.evalJS('document.getElementById(\"inner-content\").getElementsByTagName(\"p\").item(0).innerHTML'));\r\n});\r\nwin.add(view);\r\nwin.open();{code}\r\n\r\n{code:title=myapp.htm}\r\n\r\n\r\n\r\n\r\nThis is the title\r\n\r\n\r\n
\r\n\t

Testing Titanium

\r\n\t
\r\n\t

This is the content

\r\n\t
\r\n
\r\n\r\n\r\n{code}", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-06-18T14:56:48.000+0000", "updated": "2011-06-18T14:56:48.000+0000" }, { "id": "157092", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Note this ticket is duplicated in TIMOB-3539", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-06-18T15:08:28.000+0000", "updated": "2011-06-18T15:08:28.000+0000" }, { "id": "158927", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as invalid due to comments from Paul.", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-07-07T11:12:08.000+0000", "updated": "2011-07-07T11:12:08.000+0000" }, { "id": "165637", "author": { "name": "ulaikamor", "key": "ulaikamor", "displayName": "Michel Leong", "active": true, "timeZone": "America/Los_Angeles" }, "body": "When I try to run the example provided above by Paul, it crashes and the output is as follows:\r\n\r\n{noformat}\r\nD/TiWebViewBinding( 319): (main) [2408,2971] getJSValue:javascript:_TiReturn.setValue((function(){try{return document.title+\"\";}catch(ti_eval_err){return '';}})());\r\nW/dalvikvm( 319): JNI WARNING: jarray 0x40610110 points to non-array object (Ljava/lang/String;)\r\nI/dalvikvm( 319): \"WebViewCoreThread\" prio=5 tid=14 NATIVE\r\nI/dalvikvm( 319): | group=\"main\" sCount=0 dsCount=0 obj=0x405ac350 self=0x219b10\r\nI/dalvikvm( 319): | sysTid=377 nice=0 sched=0/0 cgrp=default handle=2202696\r\nI/dalvikvm( 319): | schedstat=( 507256989 1098467084 111 )\r\nI/dalvikvm( 319): at android.webkit.BrowserFrame.stringByEvaluatingJavaScriptFromString(Native Method)\r\nI/dalvikvm( 319): at android.webkit.BrowserFrame.stringByEvaluatingJavaScriptFromString(Native Method)\r\nI/dalvikvm( 319): at android.webkit.BrowserFrame.loadUrl(BrowserFrame.java:246)\r\nI/dalvikvm( 319): at android.webkit.WebViewCore.loadUrl(WebViewCore.java:1570)\r\nI/dalvikvm( 319): at android.webkit.WebViewCore.access$1400(WebViewCore.java:53)\r\nI/dalvikvm( 319): at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:956)\r\nI/dalvikvm( 319): at android.os.Handler.dispatchMessage(Handler.java:99)\r\nI/dalvikvm( 319): at android.os.Looper.loop(Looper.java:123)\r\nI/dalvikvm( 319): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629)\r\nI/dalvikvm( 319): at java.lang.Thread.run(Thread.java:1019)\r\nI/dalvikvm( 319): \r\nE/dalvikvm( 319): VM aborting\r\nI/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\r\nI/DEBUG ( 31): Build fingerprint: 'generic/google_sdk/generic:2.3.1/GSI11/93351:eng/test-keys'\r\nI/DEBUG ( 31): pid: 319, tid: 377 >>> com.nokiasiemens.reporting <<<\r\nI/DEBUG ( 31): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadd00d\r\nI/DEBUG ( 31): r0 fffffebc r1 deadd00d r2 00000026 r3 00000000\r\nI/DEBUG ( 31): r4 81da45c8 r5 40610110 r6 81d859ec r7 0021a540\r\nI/DEBUG ( 31): r8 44026b50 r9 43efbe20 10 43efbe08 fp 4168d82c\r\nI/DEBUG ( 31): ip 81da4728 sp 44026678 lr afd19375 pc 81d45a02 cpsr 20000030\r\n{noformat}\r\n\r\nPlease check this issue.\r\n\r\nThank you.\r\n", "updateAuthor": { "name": "ulaikamor", "key": "ulaikamor", "displayName": "Michel Leong", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-09-12T08:54:42.000+0000", "updated": "2011-09-12T08:54:42.000+0000" }, { "id": "183199", "author": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I just tested Paul's sample against master and it worked as expected on iOS, Android, and Mobile Web.\r\n\r\nNote that there is a typo in the sample. The app.js file says \"myweb.htm\", but the filename is listed as \"myapp.htm\"--if you use this sample verbatim, you'll get nothing back from the evalJS methods. However, with the filename corrected, it works fine.\r\n\r\n", "updateAuthor": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-15T10:14:17.000+0000", "updated": "2012-02-15T10:14:17.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }