{ "id": "82392", "key": "AC-2795", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2011-12-28T06:37:32.000+0000", "created": "2011-11-06T16:07:40.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "updated": "2016-03-08T07:47:43.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "h2. Problem\r\n\r\n{{Ti.UI.iPhone.NavigationGroup.close()}} crashes with EXC_BAD_ACCESS\r\n\r\nh2. Test case\r\n\r\nWhen using an unmodified 1.8.20111028x CI build, the following testcase generally crashes with EXC_BAD_ACCESS after 2 to 10 presses of the \"Start Test\" button.\r\n\r\n{code:lang=javascript|title=app.js}\r\nvar root = Ti.UI.createWindow({\r\n title: 'Root Window',\r\n backgroundColor: 'white',\r\n layout: 'vertical',\r\n});\r\n\r\nvar startButton = Ti.UI.createButton({\r\n title: 'Start Test',\r\n height:'50dp',\r\n width:'200dp',\r\n top:'20dp', \r\n});\r\nstartButton.addEventListener('click', function() {\r\n // for (;;) {\r\n var windows = [], n = Math.floor(Math.random() * 10) + 3;\r\n for (var i=0; i < n; i++) {\r\n var w = Ti.UI.createWindow({\r\n title: 'Window '+i,\r\n backgroundColor: 'white',\r\n layout: 'vertical',\r\n });\r\n windows.push(w);\r\n navgroup.open(w, {animated:false});\r\n Ti.API.info('opened '+w.title);\r\n }\r\n \r\n while (windows.length > 0) {\r\n var winToClose = windows.pop();\r\n navgroup.close(winToClose, { animated: false});\r\n Ti.API.info('closed '+w.title);\r\n }\r\n // }\r\n});\r\nroot.add(startButton);\r\n\r\nvar navgroup = Ti.UI.iPhone.createNavigationGroup({\r\n window: root\r\n});\r\n\r\nvar container = Ti.UI.createWindow();\r\ncontainer.add(navgroup);\r\ncontainer.open();\r\n\r\n{code}\r\n\r\nh2. Solution\r\n\r\nRunning the app under Instruments shows that a message is being sent to a deallocated object in the {{createProxy:forName:context: method in TiModule.m}} (line 155 in the referenced build). The actual problem appears to be in the {{close:withObject: method of TiUIiPhoneNavigationGroup.m}}.\r\n\r\nThe following changes to {{TiUIiPhoneNavigationGroup.m}} resolves the issue:\r\n\r\n{code:lang=none|title=TiUIiPhoneNavigationGroup.m}\r\n@@ -117,8 +119,9 @@\r\n \tNSMutableArray* newControllers = [NSMutableArray arrayWithArray:controller.viewControllers];\r\n \tBOOL animated = [TiUtils boolValue:@\"animated\" properties:properties def:(windowController == [newControllers lastObject])];\r\n \t[newControllers removeObject:windowController];\r\n-\t[closingProxy autorelease];\r\n-\tclosingProxy = [window retain];\r\n+//\t[closingProxy autorelease];\r\n+//\tclosingProxy = [window retain];\r\n+ [window close:nil];\r\n \t[controller setViewControllers:newControllers animated:animated];\r\n \t\r\n }\r\n@@ -152,9 +155,9 @@\r\n \t\t}\r\n \t\t[self setVisibleProxy:newWindow];\r\n \t}\r\n-\t[closingProxy close:nil];\r\n-\t[closingProxy release];\r\n-\tclosingProxy = nil;\r\n+//\t[closingProxy close:nil];\r\n+//\t[closingProxy release];\r\n+//\tclosingProxy = nil;\r\n \topening = NO;\r\n \t[newWindow windowDidOpen];\r\n }\r\n{code}\r\n", "attachment": [ { "id": "24069", "filename": "app.js", "author": { "name": "pegli", "key": "pegli", "displayName": "Paul Mietz Egli", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-11-07T08:03:32.000+0000", "size": 995, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "iOS: UI.iPhone - NavigationGroup.close() crashes with EXC_BAD_ACCESS", "creator": { "name": "pegli", "key": "pegli", "displayName": "Paul Mietz Egli", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "pegli", "key": "pegli", "displayName": "Paul Mietz Egli", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "* Titanium 1.8.20111104173056\r\n* Xcode 4.2 (4D199)\r\n* OSX Lion\r\n* iOS 5.0", "comment": { "comments": [ { "id": "171713", "author": { "name": "pegli", "key": "pegli", "displayName": "Paul Mietz Egli", "active": true, "timeZone": "America/Los_Angeles" }, "body": "After some additional testing, I was able to avoid the leak by making the following changes to TiUIiPhoneNavigationGroup.m:\r\n\r\n{code}\r\n@@ -117,8 +119,9 @@\r\n \tNSMutableArray* newControllers = [NSMutableArray arrayWithArray:controller.viewControllers];\r\n \tBOOL animated = [TiUtils boolValue:@\"animated\" properties:properties def:(windowController == [newControllers lastObject])];\r\n \t[newControllers removeObject:windowController];\r\n-\t[closingProxy autorelease];\r\n-\tclosingProxy = [window retain];\r\n+//\t[closingProxy autorelease];\r\n+//\tclosingProxy = [window retain];\r\n+ [window close:nil];\r\n \t[controller setViewControllers:newControllers animated:animated];\r\n \t\r\n }\r\n@@ -152,9 +155,9 @@\r\n \t\t}\r\n \t\t[self setVisibleProxy:newWindow];\r\n \t}\r\n-\t[closingProxy close:nil];\r\n-\t[closingProxy release];\r\n-\tclosingProxy = nil;\r\n+//\t[closingProxy close:nil];\r\n+//\t[closingProxy release];\r\n+//\tclosingProxy = nil;\r\n \topening = NO;\r\n \t[newWindow windowDidOpen];\r\n }\r\n{code}", "updateAuthor": { "name": "pegli", "key": "pegli", "displayName": "Paul Mietz Egli", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-11-06T19:12:15.000+0000", "updated": "2011-11-06T19:12:15.000+0000" }, { "id": "171726", "author": { "name": "pegli", "key": "pegli", "displayName": "Paul Mietz Egli", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I've attached sample code to help reproduce the crash. When using an unmodified 1.8.20111028x CI build, the app generally crashes for me after one or two presses of the \"Start Test\" button. If TiUIiPhoneNavigationGroup.m is modified as described above, the code runs fine. ", "updateAuthor": { "name": "pegli", "key": "pegli", "displayName": "Paul Mietz Egli", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-11-07T08:03:32.000+0000", "updated": "2011-11-07T08:09:21.000+0000" }, { "id": "177387", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Paul\r\n\r\nDo you know if this has been resolved in 1.8.0.1? Does your test case still exhibit the same issue?\r\n\r\nThank you for including the solution to this. In order for us to use any of your code, you will need to sign the CLA. See [Signing the Contributors License Agreement (CLA)|https://wiki.appcelerator.org/display/guides/How+to+Contribute+Code#HowtoContributeCode-SigningtheContributorsLicenseAgreement%28CLA%29] for info. Have you done this, or do we need to organize it?\r\n\r\nThanks", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-28T06:37:05.000+0000", "updated": "2011-12-28T06:37:05.000+0000" }, { "id": "183532", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Closing due to inactivity. If this issue still exists, please raise a new ticket, including all the information in the [JIRA Ticket Checklist|https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist] to ensure that we can escalate it quickly. Read [How to Submit a Bug Report|https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report] if you have not read it before, and always start a ticket using the [JIRA Ticket Template|https://wiki.appcelerator.org/display/guides/JIRA+Ticket+Template].\r\n\r\nThanks in advance", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2012-02-17T02:23:00.000+0000", "updated": "2012-02-17T02:23:00.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }