{ "id": "87214", "key": "TIMOB-7876", "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": "12593", "name": "Release 2.0.0", "archived": false, "released": true, "releaseDate": "2012-03-30" }, { "id": "13170", "name": "Sprint 2012-06", "archived": true, "released": true, "releaseDate": "2012-03-25" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-03-14T11:54:33.000+0000", "created": "2012-03-01T08:42:02.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "crash", "module_view", "qe-testadded", "regression", "release-note-2.0.0" ], "versions": [], "issuelinks": [ { "id": "15746", "type": { "id": "10000", "name": "Blocks", "inward": "is blocked by", "outward": "blocks" }, "outwardIssue": { "id": "86833", "key": "TIMOB-7775", "fields": { "summary": "Android: Master/Detail Template: intermittent crash on use", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-07-05T12:03:26.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": "h2.Problem\r\nWhen Ti.App.addEventListener() is called from a commonJS unit, other attempts to add an event listener to Ti.App on the same event in normal app units, and then remove that event listener, causes a crash:\r\n{noformat}----- Titanium Javascript Runtime Error -----\r\nE/TiJSError( 667): (main) [1,3676] - In ti:/events.js:241,23\r\nE/TiJSError( 667): (main) [0,3676] - Message: Uncaught TypeError: Cannot read property '0' of undefined\r\nE/TiJSError( 667): (main) [0,3676] - Source: \t\t\t\t\tif (list.listener[i] === listener ||\r\nE/V8Exception( 667): Exception occurred at ti:/events.js:241: Uncaught TypeError: Cannot read property '0' of undefined{noformat}\r\n\r\n*This is a regression*, as it did not occur in SDK 1.8.1.\r\n\r\nh2.Testcase\r\nTi.App.addEventListener(a,b) is called from a commonJS unit. Another Ti.App.addEventListener(a,c) is called from app.js (notice that the first parameter, the event name, is the same in both calls). Also in app.js, Ti.App.removeEventListener(a,c) is called, which causes the crash.\r\n\r\nPut the following code into a new Ti mobile project and run it to the emulator. The crash occurs without any interaction, as soon as the main window appears.\r\n\r\n{code:title=app.js}\r\nvar Procs=require('CommonProcs');\r\nProcs.FirstStep();\r\n\r\nvar win1=Ti.UI.createWindow({\r\n exitOnClose:true,\r\n navBarHidden:true\r\n })\r\n\r\nvar TheLabel=Ti.UI.createLabel({\r\n color:'white',\r\n text:'Hello World',\r\n width:'auto'\r\n });\r\nwin1.add(TheLabel);\r\nwin1.open();\r\n\r\n\r\nfunction MainWinOrientationChange()\r\n{\r\n Ti.API.info('MainWinOrientationChange');\r\n}\r\nTi.App.addEventListener('CustomOrientationChange',MainWinOrientationChange);\r\nTi.App.removeEventListener('CustomOrientationChange',MainWinOrientationChange);\r\n{code}\r\n{code:title=CommonProcs.js}\r\nexports.FirstStep=function()\r\n{\r\n function EmbededHandler()\r\n {\r\n Ti.API.info('test');\r\n }\r\n\r\n // Removing the following line or changing the first parameter\r\n // causes the crash to not occur.\r\n Ti.App.addEventListener('CustomOrientationChange',EmbededHandler);\r\n};\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Android: Ti.App.addEventListener() from a commonJS unit causes later Ti.App.removeEventListener() to crash", "creator": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "environment": "- Titanium Mobile SDK 1.8.2 (and 1.8.2.v20120221114636)\r\n- Android 2.2 emulator\r\n- Windows 7\r\n- Titanium Studio 1.0.9.201202141208\r\n", "comment": { "comments": [ { "id": "184867", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "I can confirm this issue for component-based events. I didn't try to isolate the issue, but I not using app-level events and I'm getting this error message when I compile app with 1.8.2 (1.8.1 don't have this issue).", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2012-03-02T03:24:03.000+0000", "updated": "2012-03-02T03:24:03.000+0000" }, { "id": "185303", "author": { "name": "arnaud", "key": "arnaud", "displayName": "Arnaud Besnier", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I confirm that I have the same issue with SDK 1.8.2 :\r\nwhen a window (with an event listener associated to it) is closed I have the same Javascript Runtime Error.\r\n\r\nThe event listeners manager may not be able to find and delete the event listener associated to the window closed...\r\n\r\nI also confirm that the bug is not present in SDK 1.8.1.", "updateAuthor": { "name": "arnaud", "key": "arnaud", "displayName": "Arnaud Besnier", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-03-07T00:42:50.000+0000", "updated": "2012-03-07T00:42:50.000+0000" }, { "id": "185357", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Has this fix been merged into the 1_8_X branch?", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-03-07T09:35:59.000+0000", "updated": "2012-03-07T09:35:59.000+0000" }, { "id": "186900", "author": { "name": "dhyde", "key": "dhyde", "displayName": "Dustin Hyde", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as Fixed.\r\n\r\nTested with Ping's code.\r\n\r\nExpected Behavior: Removing event listeners will not cause the associated runtime error.\r\n\r\nSDK: 2.0.0.v20120316130302\r\nAndroid: V8, Rhino\r\nStudio: 2.0.0.201203152033\r\nOS: Snow Leopard\r\nDevices Tested: Nexus One 2.2.2\r\n\r\nNote: This bug does not involve CommonJS Modules.", "updateAuthor": { "name": "dhyde", "key": "dhyde", "displayName": "Dustin Hyde", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-03-16T15:28:44.000+0000", "updated": "2012-03-16T15:28:44.000+0000" }, { "id": "187152", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Verified fix on SDK 2.0.0.v20120319003254. Thanks!", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-03-19T12:58:46.000+0000", "updated": "2012-03-19T12:58:46.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }