{ "id": "152078", "key": "TIMOB-20041", "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": "16997", "name": "Release 5.2.0", "archived": false, "released": true, "releaseDate": "2016-02-23" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-03-16T09:58:09.000+0000", "created": "2015-10-15T11:58:31.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "Community", "ios", "mainthread", "sdk-5.0.2" ], "versions": [], "issuelinks": [], "assignee": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-16T09:58:09.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": "When opening a new window with a ListView from within a NavigationWindow, the close event of this window sometimes get fired and sometimes won't.\r\n\r\nExample:\r\n\r\n{code:xml|title=win1.xml}\r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n{code}\r\n\r\n{code:javascript|title=win1.js}\r\nfunction openBlueWindow(e) {\r\n var win2 = Alloy.createController('win2').getView();\r\n win2.addEventListener(\"close\", function() {\r\n console.log(\"CLOSED!\");\r\n });\r\n $.navwin.openWindow(win2);\r\n}\r\n{code}\r\n\r\n$.navwin.open();\r\n\r\n{code:xml|title=win2.xml}\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n{code}\r\n\r\n{code:javascript|title=win2.js}\r\nfunction closeWindow(){\r\n $.win2.close();\r\n}\r\n{code}\r\n\r\nWhen you close window 2 the expected behaviour is to see \"CLOSED!\" in the console, but it only randomly shows.", "attachment": [], "flagged": false, "summary": "iOS: Window close event not fired on NavigationWindow with ListView", "creator": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "environment": "SDK 5.0.2.GA\r\nMac OS Yosemite\r\niOS 9.0 iPhone simulator\r\nXcode 7", "closedSprints": [ { "id": 597, "state": "closed", "name": "2016 Sprint 06 SDK", "startDate": "2016-03-12T01:30:59.982Z", "endDate": "2016-03-26T00:30:00.000Z", "completeDate": "2016-03-28T03:38:09.726Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "366931", "author": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "body": "Happens on iOS 9 simulator with SDK 5.0.0.GA and above.\r\nHappens on iOS 8.4 simulator on SDK 5.0.0.GA and above, so SDK 4.1.1.GA is okay on iOS 8.4.", "updateAuthor": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-10-15T12:19:30.000+0000", "updated": "2015-10-19T07:58:27.000+0000" }, { "id": "367129", "author": { "name": "gertjans", "key": "gertjans", "displayName": "Gertjan Smits", "active": true, "timeZone": "Europe/Berlin" }, "body": "Took me a while to figure out what went wrong, but I also have this issue, in a classic project, I prepared my testcase before I found this ticket, so I'm submitting it anyway:\r\n\r\n{code:javascript}\r\nvar mainWindow = Titanium.UI.createWindow({\r\n\tbackgroundColor: '#fff'\r\n});\r\n\r\nmainWindow.open();\r\n\r\nsetTimeout(openWindow, 2500);\r\n\r\nfunction openWindow() {\r\n\tvar anotherWindow = Ti.UI.createWindow({\r\n\t\tbackgroundColor: '#fff'\r\n\t});\r\n\r\n\tvar listView = Ti.UI.createListView({\r\n\t\twidth: Ti.UI.FILL,\r\n\t\theight: Ti.UI.FILL,\r\n\t\tdefaultItemTemplate: 'defaultTemplate',\r\n\t\ttemplates: {\r\n\t\t\t'defaultTemplate': {\r\n\t\t\t\tproperties: {\r\n\t\t\t\t\twidth: Ti.UI.FILL,\r\n\t\t\t\t\theight: 100\r\n\t\t\t\t},\r\n\t\t\t\tchildTemplates: [{\r\n\t\t\t\t\ttype: 'Ti.UI.Label',\r\n\t\t\t\t\tbindId: 'label',\r\n\t\t\t\t\tproperties: {\r\n\t\t\t\t\t\ttouchEnabled: false,\r\n\t\t\t\t\t\twidth: Ti.UI.FILL,\r\n\t\t\t\t\t\theight: Ti.UI.SIZE\r\n\t\t\t\t\t}\r\n\t\t\t\t}]\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n\r\n\tlistView.sections = [Ti.UI.createListSection({\r\n\t\titems: [{\r\n\t\t\tlabel: {\r\n\t\t\t\ttext: \"Wow a row\"\r\n\t\t\t}\r\n\t\t}, {\r\n\t\t\tlabel: {\r\n\t\t\t\ttext: \"Another row!\"\r\n\t\t\t}\r\n\t\t}]\r\n\t})];\r\n\r\n\tanotherWindow.add(listView);\r\n\r\n\t// handlers\r\n\tanotherWindow.addEventListener('close', function() {\r\n\t\t// this is never executed\r\n\t\tTi.API.info('- window close handler');\r\n\t});\r\n\r\n\tanotherWindow.addEventListener('open', function() {\r\n\t\tTi.API.info('- window open handler');\r\n\t});\r\n\r\n\t//\r\n\tTi.API.info(\"opening window...\");\r\n\tanotherWindow.open();\r\n\r\n\tsetTimeout(function() {\r\n\t\tTi.API.info(\"calling close...\");\r\n\t\tanotherWindow.close();\r\n\t}, 5000);\r\n}\r\n{code}", "updateAuthor": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-10-19T11:29:54.000+0000", "updated": "2016-03-10T23:00:33.000+0000" }, { "id": "367130", "author": { "name": "gertjans", "key": "gertjans", "displayName": "Gertjan Smits", "active": true, "timeZone": "Europe/Berlin" }, "body": "For some reason my code in my above comment is indented kind of weird, but on a colleagues screen it looks fine, to be sure, I've put it here: [http://jsfiddle.net/GertjanSmits/fqkdw8pe/].", "updateAuthor": { "name": "gertjans", "key": "gertjans", "displayName": "Gertjan Smits", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-10-19T11:39:34.000+0000", "updated": "2015-10-19T11:39:34.000+0000" }, { "id": "367140", "author": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "body": "Good to hear (not for you of course) I'm not the only one as I was beginning to think I did something wrong. Strange no one else noticied this before. Hopefully someone of Appcelerator picks this one up!", "updateAuthor": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-10-19T14:14:33.000+0000", "updated": "2015-10-19T14:14:33.000+0000" }, { "id": "371342", "author": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "I have EXACTLY the same problem!!\r\nI have it on iOS and Android on my both apps.\r\nSame problem appears everywhere, devices, emulator and it's exactly as you said, on a random way.\r\nIt looks like sometimes \"something\" is removing the \"close\" event listener that I attached before and it's annoying since all application is based on that.\r\nI had never that problem before SDK 5 and I'm with Titanium since SDK 1.7", "updateAuthor": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2015-11-24T12:47:00.000+0000", "updated": "2015-11-24T12:47:00.000+0000" }, { "id": "371343", "author": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "body": "I have not experienced this on Android, but as it's random behaviour, maybe I just did not noticed it yet. I also build much of my application actions around the close event, for example do some API calls after a window is closed. So this is a VERY big bug for me too!", "updateAuthor": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-11-24T14:03:22.000+0000", "updated": "2015-11-24T14:03:22.000+0000" }, { "id": "371345", "author": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "Same here. Lots based on that close event and YES it's s big bug for me and I don't know what to do to tweak the situation.\r\nI have a feeling it's a bug in a garbage collector or something like that because event somehow get lost :(", "updateAuthor": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2015-11-24T14:23:56.000+0000", "updated": "2015-11-24T14:23:56.000+0000" }, { "id": "379476", "author": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~michielve] Hello , could you please try the sample code provided by Gertjan , with the newest SDK which can be found [here|http://builds.appcelerator.com.s3.amazonaws.com/index.html#5_2_X]. I ran the code multiple times and the event handler for the windows close is being called. If you are still having the issue after testing with the new SDK, I will investigate this further !\r\n{code:javascript}\r\nvar mainWindow = Titanium.UI.createWindow({\r\n\tbackgroundColor: '#fff'\r\n});\r\n \r\nmainWindow.open();\r\n \r\nsetTimeout(openWindow, 2500);\r\n \r\nfunction openWindow() {\r\n\tvar anotherWindow = Ti.UI.createWindow({\r\n\t\tbackgroundColor: '#fff'\r\n\t});\r\n \r\n\tvar listView = Ti.UI.createListView({\r\n\t\twidth: Ti.UI.FILL,\r\n\t\theight: Ti.UI.FILL,\r\n\t\tdefaultItemTemplate: 'defaultTemplate',\r\n\t\ttemplates: {\r\n\t\t\t'defaultTemplate': {\r\n\t\t\t\tproperties: {\r\n\t\t\t\t\twidth: Ti.UI.FILL,\r\n\t\t\t\t\theight: 100\r\n\t\t\t\t},\r\n\t\t\t\tchildTemplates: [{\r\n\t\t\t\t\ttype: 'Ti.UI.Label',\r\n\t\t\t\t\tbindId: 'label',\r\n\t\t\t\t\tproperties: {\r\n\t\t\t\t\t\ttouchEnabled: false,\r\n\t\t\t\t\t\twidth: Ti.UI.FILL,\r\n\t\t\t\t\t\theight: Ti.UI.SIZE\r\n\t\t\t\t\t}\r\n\t\t\t\t}]\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n \r\n\tlistView.sections = [Ti.UI.createListSection({\r\n\t\titems: [{\r\n\t\t\tlabel: {\r\n\t\t\t\ttext: \"Wow a row\"\r\n\t\t\t}\r\n\t\t}, {\r\n\t\t\tlabel: {\r\n\t\t\t\ttext: \"Another row!\"\r\n\t\t\t}\r\n\t\t}]\r\n\t})];\r\n \r\n\tanotherWindow.add(listView);\r\n \r\n\t// handlers\r\n\tanotherWindow.addEventListener('close', function() {\r\n\t\t// this is never executed\r\n\t\tTi.API.info('- window close handler');\r\n\t});\r\n \r\n\tanotherWindow.addEventListener('open', function() {\r\n\t\tTi.API.info('- window open handler');\r\n\t});\r\n \r\n\t//\r\n\tTi.API.info(\"opening window...\");\r\n\tanotherWindow.open();\r\n \r\n\tsetTimeout(function() {\r\n\t\tTi.API.info(\"calling close...\");\r\n\t\tanotherWindow.close();\r\n\t}, 5000);\r\n}\r\n{code}", "updateAuthor": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-10T23:02:28.000+0000", "updated": "2016-03-10T23:03:36.000+0000" }, { "id": "379732", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Just to troubleshoot: Does this work with {{true}} enabled in the {{}} section of your tiapp.xml? It looks very suspicious to be a main-thread issue.\r\n\r\nEDIT: Created an easy-to-run example of your original alloy-demo: https://gist.github.com/hansemannn/ab83c7730999b7ea3100 Would be very interesting to see if it works with main-thread enabled (which will be default in the 5.4.0 release)", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-15T10:28:04.000+0000", "updated": "2016-03-15T10:42:13.000+0000" }, { "id": "379737", "author": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "I wanted to test your \"run-on-main-thread\" suggestion but before that, I tried to test it again (because SDK updated couple times since then). So, I noticed that somehow the problem is gone and all works fine now!!:)\r\nIt looks like last update of SDK 5.2.0GA fix that issue.\r\n\r\nI tested on iOS emulator 9.2 (iPhone6S), SDK 5.2.0GA and it's working great now!\r\nTested also on Genymotion emulator (for Android), SDK 5.2.0GA - Also works great now!\r\n\r\nBtw, in the title appears \"*+iOS+*: Window close event not fired on NavigationWindow with ListView\". I am sure the same problem was for Android as well. I tested it couple of times and *+Android had the same problem+*!", "updateAuthor": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2016-03-15T12:02:37.000+0000", "updated": "2016-03-15T12:02:37.000+0000" }, { "id": "379738", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks for the feedback [~mry], appreciate that! Android and iOS are developed independently, so that might have been another (already fixed) issue. Also note, that the {{}} fix is not enabled by default in 5.2.0.GA. Although you can enable it and most of your code will work like a charm, it is not 100 % stable for all use-cases, yet. This will be part of the upcoming 5.4.0.GA release in a few months.\r\n\r\nWe will wait for other ticket watchers to confirm that the above solution works for them and close it after that. Thanks guys!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-15T12:30:27.000+0000", "updated": "2016-03-15T12:30:27.000+0000" }, { "id": "379740", "author": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "updateAuthor": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2016-03-15T13:19:56.000+0000", "updated": "2016-03-15T13:19:56.000+0000" }, { "id": "379741", "author": { "name": "twiesen", "key": "twiesen", "displayName": "Thomas Wiesen", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I can also confirm that the bug seems to have been fixed with version 5.2.0.GA. :)\r\nThanks!", "updateAuthor": { "name": "twiesen", "key": "twiesen", "displayName": "Thomas Wiesen", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-15T13:20:53.000+0000", "updated": "2016-03-15T13:20:53.000+0000" }, { "id": "379743", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-15T13:23:20.000+0000", "updated": "2016-03-15T13:23:20.000+0000" }, { "id": "379851", "author": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "body": "I can also confirm that with iOS 9.2 + SDK 5.2.0.GA this issue seems to be resolved!\r\n\r\nMany thanks!\r\n\r\nNote: I did not do anything with run-on-main-thread, so I guess the default is used for SDK 5.2.0.GA.", "updateAuthor": { "name": "michielve", "key": "michielve", "displayName": "Michiel van Eerd", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-16T09:51:57.000+0000", "updated": "2016-03-16T09:51:57.000+0000" }, { "id": "379853", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Reporter and watchers confirmed that the issue is fixed with latest 5.2.0.GA", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-16T09:58:09.000+0000", "updated": "2016-03-16T09:58:09.000+0000" } ], "maxResults": 18, "total": 18, "startAt": 0 } } }