{ "id": "63879", "key": "TIMOB-3247", "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": [], "resolution": { "id": "10100", "description": "This issue won't be actioned.", "name": "Won't Do" }, "resolutiondate": "2020-01-09T18:50:55.000+0000", "created": "2011-04-15T03:40:21.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-01-09T18:50:55.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": "{html}

Titanium.App.fireEvent from a html page to the underlying app.hs\nfile in iPhone have been possible from the \"html: htmlString\"\nproperty of a webview for a long time. (The \"url: page\" property\nwould however not work)

\n

Up until 1.5.1 this was possible in Android too, using either\nthe \"url: page\" property or the \"html: htmlString\" property of the\nwebView.

\n

In SDK 1.6.0 both seems to work on the Android Emulator, but on\nthe device these are not triggered at all. On the 1.5.1 SDK these\nare picked up on the device from both the url and the html property\non the device, but none of these works on the device in the 1.6.0\nSDK release.

\n

It would be fine if it only worked from the \"html\" property as\non the iPhone, but now interaction between the html page and the\nunderlying app.js file does not work anymore in Android.

\n

I have been testing on a Android device (Galaxy 9000S running\nAPIs 2.1)

\n

On the emulator all api's from 1.6 till 2.2 seems to work\nok.

{html}", "attachment": [], "flagged": false, "summary": "Titanium.App.fireEvent from html stopped working in Android from 1.6.0", "creator": { "name": "haraldsakshaug", "key": "haraldsakshaug", "displayName": "Harald Sakshaug", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "haraldsakshaug", "key": "haraldsakshaug", "displayName": "Harald Sakshaug", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "130374", "author": { "name": "haraldsakshaug", "key": "haraldsakshaug", "displayName": "Harald Sakshaug", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Typo in ticket: app.hs should be app.js.

{html}", "updateAuthor": { "name": "haraldsakshaug", "key": "haraldsakshaug", "displayName": "Harald Sakshaug", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:22.000+0000", "updated": "2011-04-15T03:40:22.000+0000" }, { "id": "130375", "author": { "name": "aaronk.saunders", "key": "aaronk.saunders", "displayName": "Aaron K. Saunders", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I am getting a crash when ever i attempt to fire an event from\ninside a webView, I will do some more testing and write a simple\napp to verify

{html}", "updateAuthor": { "name": "aaronk.saunders", "key": "aaronk.saunders", "displayName": "Aaron K. Saunders", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:22.000+0000", "updated": "2011-04-15T03:40:22.000+0000" }, { "id": "130376", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "{html}

Harald, is your HTML well formed? If you don't have and the Ti\nscripts won't have anywhere to get injected, and so they won't be\ninjected.

\n

For example, this script should alert that Ti.App.fireEvent is a\nfunction, but it will not:

\n
\nvar web = Ti.UI.createWebView({\n    html: 'hi'\n});\nweb.addEventListener('load', function() {\n    web.evalJS('alert(Ti.App.fireEvent);');\n});\n
\n

while this script will, when all I have changed is adding the\nproper HTML elements:

\n
\nvar web = Ti.UI.createWebView({\n    html: '<html><head></head><body>hi</body></html>'\n});\nweb.addEventListener('load', function() {\n    web.evalJS('alert(Ti.App.fireEvent);');\n});\n
\n

Can you verify that you are seeing the same behavior? I have\nonly tested this on the iPhone Simulator 4.2.

{html}", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-04-15T03:40:22.000+0000", "updated": "2011-04-15T03:40:22.000+0000" }, { "id": "130377", "author": { "name": "haraldsakshaug", "key": "haraldsakshaug", "displayName": "Harald Sakshaug", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Hi Dawson,

\n

It works perfect on the iPhone and the iPhone simulator using\nthe html property. I pull the HTML from the server and inject it\ninto the webview using the HTML property-

\n

This works fine sin the Android Emulator as well. Both using the\nHTML property and injecting downloaded HTML, and the url propery\npointing to the external file.

\n

The problem is the Android Device where neither method\nworks.
\nIf i compile with the 1.5.1 it works perfectly on the device too\nusing the url property, but compiling with 1.6.0 breaks it.

\n

The HTML i load is pulled from this url:
\nhttp://turisme.nextcon.no/tourlist.aspx

\n

One odd behaviour I have seen is that it appear to work for one\nbuild in 1.6.0 if I just compile it in 1.5.1 first. I havent been\ntesting enough to see thatt this is perfect every time, but it\nappears that building 1.5.1 and immediately building 1.6.0\nafterwards it work for that first build only.

\n

I sort of have put it aside waiting for someone to look at this\nerror report.

\n

Thanks, Harald.

{html}", "updateAuthor": { "name": "haraldsakshaug", "key": "haraldsakshaug", "displayName": "Harald Sakshaug", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:22.000+0000", "updated": "2011-04-15T03:40:22.000+0000" }, { "id": "130378", "author": { "name": "danb", "key": "danb", "displayName": "Dan B", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I can confirm custom events are not firing from within web views\nin Linux Android 1.6.1 Mar 11 2011 18:20 r2732315a (web view ui\nevents fire fine, issue is from within webview). However, they do\nappear to be firing in OSX iOS 1.6.0.

{html}", "updateAuthor": { "name": "danb", "key": "danb", "displayName": "Dan B", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:22.000+0000", "updated": "2011-04-15T03:40:22.000+0000" }, { "id": "130379", "author": { "name": "juliang", "key": "juliang", "displayName": "Julian G", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I want to highlight this issue as being potentially quite a\nmajor one. As things stand, there is an entire category of app\n(those requiring communication between a web view and the container\napp) that this issue makes it nearly impossible to implement on\nAndroid devices when using Titanium.

\n

I implemented a pretty basic RSS news feeder app which pulls\ncontent from a server and displays that content using a mixture of\nnative screens and web views. The web views are used to display\nHTML content loaded from the feed. The HTML is generated from the\nfeed contents and is passed to the web view using its 'html'\nproperty (all content is valid HTML). The HTML includes buttons\nwhich, when clicked, request navigation to a new screen by using\nTi.App.fireEvent to raise an application level event.

\n

Using mobile SDK 1.6, the app worked perfectly on iOS but was\nhopelessly broken on Android as the event handlers (registered\nusing Ti.App.addEventListener) would never receive any events.\nAfter an epic hack session, I eventually coded a work around by\nregistering a click event handler on the web view, re-injecting the\nevent into the web view using evalJS and then extracting the\nrequired Ti.App event by the same route. Even then, I could only\nget the events to their destination by moving the listener\nregistration from the Ti.App object to the web view object, and by\ncalling fireEvent on the web view object once the event had been\ndug out of the web view:

\n
\n// Dig application level events out of the web view when a click event happens\nwebView.addEventListener('click',function() {\n    // This solution requires a load of JS code in the web view.\n    var e = webView.evalJS('injectClickEvent()');\n    if( e ) {\n        e = JSON.parse( e );\n        // Calling Ti.App.fireEvent won't work...\n        webView.fireEvent( e.n, e.e );\n    }\n});\n// This listener on Ti.App won't work...\nwebView.addEventListener('some-application-level-event', myEventHandler );\n
\n

This problem seems to exist only for multi-window apps defined\nover multiple files. If I create a trivial app in a single app.js\nlike the following, then it all works OK:

\n
\nvar webView = Ti.UI.createWebView({\n    html:'<html><input type=\"button\" value=\"test\" onclick=\"Ti.App.fireEvent(\\\"test\\\")\"/></html>';\n});\nTi.App.addEventListener('test', function() { ... });\n// etc...\n
\n

To reiterate, this was only a problem on Android. Also, the\nproblem does not seem to be confined to the 1.6.0 sdk; I tested on\n1.6.1 and 1.5.1 and had the same issues on both.

\n

What I'm describing is probably only part of a more fundamental,\nJS scope related problem, as I also encountered occasional problems\nfiring events from within JS closures, but I'm highlighting this\nproblem as it was considerably more difficult to work around.

{html}", "updateAuthor": { "name": "juliang", "key": "juliang", "displayName": "Julian G", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:23.000+0000", "updated": "2011-04-15T03:40:23.000+0000" }, { "id": "130380", "author": { "name": "kt", "key": "kt", "displayName": "KT", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Are you seeing a message in your trace log along the lines of\n\"E/Web Console( 504): ReferenceError: Can't find variable: Ti at\nfile: ...\" ?

\n

Because I'm seeing that as per \nthis.

\n

(I'm also trying to figure out if and how it's related to the\nfact that evalJS() simply \ncrashes on 2.2.)

{html}", "updateAuthor": { "name": "kt", "key": "kt", "displayName": "KT", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:23.000+0000", "updated": "2011-04-15T03:40:23.000+0000" }, { "id": "130381", "author": { "name": "juliang", "key": "juliang", "displayName": "Julian G", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Kt - No errors are raised, and the Ti object is resolvable.

{html}", "updateAuthor": { "name": "juliang", "key": "juliang", "displayName": "Julian G", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:23.000+0000", "updated": "2011-04-15T03:40:23.000+0000" }, { "id": "130382", "author": { "name": "kt", "key": "kt", "displayName": "KT", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

So I'm the only one seeing these, repeatedly and reproduceably\nwith a minimal app.js?

{html}", "updateAuthor": { "name": "kt", "key": "kt", "displayName": "KT", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:23.000+0000", "updated": "2011-04-15T03:40:23.000+0000" }, { "id": "130383", "author": { "name": "haraldsakshaug", "key": "haraldsakshaug", "displayName": "Harald Sakshaug", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I can do some testing to see if a minimal app.js fixes or\nrepairs the problem... however...

\n

My app is not a minimal app, in which I experience the problem\nwith broken communication between appcelerator and the html. I am\nnot even certain if I am able to convert it to be that even,\nneeding both timers and the GPS on the Android which only runs\nproperly if the app have a proper activity (eg. no minimal app, but\nrunning from its own .js file, probably fullscreen even...)

\n

My initial info still holds tho, it do not work on the device,\nbut perfectly on the iPhone, iPhone simulator and the Android\nemulator. Having to convert to minial app.js is not satisfactory or\neven possible for me sadly enough, to much functionality depends on\nthe proper activity.

\n

I would like to see this error lifted from \"low\" and to be fixed\n:)

{html}", "updateAuthor": { "name": "haraldsakshaug", "key": "haraldsakshaug", "displayName": "Harald Sakshaug", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:24.000+0000", "updated": "2011-04-15T03:40:24.000+0000" }, { "id": "132843", "author": { "name": "jgoacher", "key": "jgoacher", "displayName": "Julian Goacher", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Oh well - after further changes to our project, Titanium stopped detecting even click events on the webview object, which killed the fix described above. Tried using touchend events instead, but this crashes the app after a swipe gesture. Upshot is that despite over a month's worth of dev effort on the project, we have given up trying to use Titanium for this and instead will start again and do it natively. This issue - combined with others - make me conclude that Titanium on Android is not stable or reliable. It has some vague but fundamental problems at its core (possibly due to concurrency issues), and there is no sign of these issues being taken seriously by the dev team (presumably because they can't be recreated with simple test cases).", "updateAuthor": { "name": "jgoacher", "key": "jgoacher", "displayName": "Julian Goacher", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-27T07:31:56.000+0000", "updated": "2011-04-27T07:31:56.000+0000" }, { "id": "132855", "author": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This appears to be an Android issue. Reassigning to Don Thorp for triage.", "updateAuthor": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-27T09:53:43.000+0000", "updated": "2011-04-27T09:53:43.000+0000" }, { "id": "133400", "author": { "name": "jgoacher", "key": "jgoacher", "displayName": "Julian Goacher", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I added a comment to the Q&A section highlighting a serious problem which I think is relevant to this issue: http://developer.appcelerator.com/question/119481/incorrect-javascript-code-evaluation-on-titanium-android\n\n(I'm following the instructions at http://developer.appcelerator.com/blog/2011/04/platform-engineering-transitioning-to-jira-for-issue-tracking.html but it should really be raised as a Jira ticket).\n\nI'd try putting together a patch to fix this myself, but the complete lack of code documentation makes it way too time consuming...", "updateAuthor": { "name": "jgoacher", "key": "jgoacher", "displayName": "Julian Goacher", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-05-11T04:44:03.000+0000", "updated": "2011-05-11T04:44:03.000+0000" }, { "id": "453544", "author": { "name": "ahutton", "key": "ahutton", "displayName": "Alan Hutton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It has been decided that this issue should be closed as “Won’t do.” This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. Updating, or creating code may not reproduce the issue reported, or be a valid test case.\r\n\r\nIf community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.", "updateAuthor": { "name": "ahutton", "key": "ahutton", "displayName": "Alan Hutton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-01-09T18:50:55.000+0000", "updated": "2020-01-09T18:50:55.000+0000" } ], "maxResults": 14, "total": 14, "startAt": 0 } } }