{ "id": "65451", "key": "TIMOB-4242", "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": "11333", "description": "Mobile 1.8.0 M01", "name": "Sprint 2011-22", "archived": true, "released": true, "releaseDate": "2011-06-06" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-06-03T14:36:32.000+0000", "created": "2011-05-18T11:11:44.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "ti.api" ], "versions": [ { "id": "11244", "name": "Release 1.7.0", "archived": true, "released": true, "releaseDate": "2011-06-13" } ], "issuelinks": [], "assignee": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-06-06T14:04:56.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "The following code produces error (below) as summarized on iOS only. The error can be circumvented by placing a call to everywhere.test() or Ti.API.info before it is called by the event in win.js (sub-context reference).\r\n\r\n{code:title=app.js|borderStyle=solid}\r\nvar everywhere = {\r\n test: function() {\r\n Ti.API.info('this is a test');\r\n }\r\n};\r\n\r\nvar win = Titanium.UI.createWindow({ \r\n url: 'win.js'\r\n});\r\n\r\nwin.everywhere = everywhere;\r\nwin.open();\r\n{code}\r\n\r\n{code:title=win.js|borderStyle=solid}\r\n({\r\n win: Ti.UI.currentWindow,\r\n everywhere: Ti.UI.currentWindow.everywhere,\r\n init: function() {\r\n var self = this;\r\n var button = Ti.UI.createButton({\r\n title: \"click me\"\r\n });\r\n button.addEventListener('click', function(e) {\r\n self.clicked();\r\n });\r\n this.win.add(button);\r\n },\r\n clicked: function() {\r\n this.everywhere.test();\r\n }\r\n}).init();\r\n{code}\r\n\r\n{noformat}\r\n[WARN] [object TopTiModule] tried to note the callback for API in the wrong thead.\r\n[WARN] Exception in event callback. {\r\nline = 6;\r\nmessage = \"-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: API)\";\r\nsourceId = 116344464;\r\nsourceURL = \"file:///scopebug/Resources/app.js\";\r\n}\r\n{noformat}", "attachment": [], "flagged": false, "summary": "Calling Ti.API.info from global object reference in sub-context causes event exception", "creator": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "osx 10.6.7, xcode 4.2, continuous build May 17 2011 23:08 ra41eefda", "comment": { "comments": [ { "id": "133895", "author": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Other users are reporting what appears to be the same issue in [a community support question|https://developer.appcelerator.com/question/119751/errors-with-latest-builds-17x-r3bed52c7-and-18x-r5a5f4522#header]. I entered another ticket (TC-10) which, although the example code is different, it may fall under the same problem.", "updateAuthor": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-05-18T13:14:59.000+0000", "updated": "2011-05-18T13:14:59.000+0000" }, { "id": "134025", "author": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[Comment on github from development team|https://github.com/appcelerator/titanium_mobile/commit/7bef2bd0bcb7abbded1b9cccbbd187ee056788d7#commitcomment-390814]", "updateAuthor": { "name": "h0tw1r3", "key": "h0tw1r3", "displayName": "Jeffrey Clark", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-05-19T20:48:14.000+0000", "updated": "2011-05-19T20:48:14.000+0000" }, { "id": "134431", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Tested and works on Android 2.2, Titanium SDK 1.7.0 (05/27/11 17:53 8be59d3...)", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-05-30T02:08:18.000+0000", "updated": "2011-05-30T02:08:18.000+0000" }, { "id": "134521", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "A client is watching this now as well.\n\nh2. Associated Helpdesk Ticket\nhttp://appc.me/c/APP-367438", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-05-31T11:53:43.000+0000", "updated": "2011-05-31T11:53:43.000+0000" }, { "id": "134834", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The fix won't make it into 1.7.0, but there's a workaround. The workaround is to put, in app.js, put as line 1:\r\n\r\nTi.API;\r\n\r\nCross-context function calls are dangerous things (It's better to use event handlers, because of threading issues. (JS objects in JSCore are not threadsafe, and cross-context function calls mean you could be modifying the same JS object at the same time.)\r\n\r\nWhen you first refer to a module, that's when it's generated and attached to the Titanium namespace. However, when you're doing a cross-context call, the Titanium namespace the function is accessing is NOT the Titanium of the context calling the function. Because it's the wrong namespace, the context that owns it refuses to register the module because it's the wrong thread (safety reasons). However, if the module was already registered in the right context, things are fine.\r\n\r\nWe pre-register UI module since it will be used. Since API module is also common, it will now be pre-registered. However, other modules won't be pre-registered.", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-06-03T13:54:53.000+0000", "updated": "2011-06-03T13:54:53.000+0000" }, { "id": "134836", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It's still not good to call cross-context, but pre-loading API is innocuous enough.", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-06-03T14:36:32.000+0000", "updated": "2011-06-03T14:36:32.000+0000" }, { "id": "140651", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified fixed with Verizon iPhone 4 (4.2.8) , Titanium Studio, build: 1.0.0.201106021621, Titanium SDK version: 1.8.0 r477c7b27. No exception, simply a warning: \n[WARN] (null)->(null) [0]->[object APIModule] is being made in a thread not owned by ", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-06-06T14:04:56.000+0000", "updated": "2011-06-06T14:04:56.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }