{ "id": "149848", "key": "TIMOB-19255", "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": "16925", "description": "WatchKit Support--all going into 5.0 now", "name": "Release 5.0.0", "archived": true, "released": true, "releaseDate": "2015-09-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-08-19T10:04:19.000+0000", "created": "2015-07-22T11:02:43.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "listview" ], "versions": [], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2015-09-16T22:04:07.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": "If you have an empty ListView and a register event listener to 'scrollstart' the app crashes directly after starting scrolling with:\r\n{code}\r\nThe application has crashed with an uncaught exception 'NSRangeException'. Reason: *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array\r\n{code}\r\n\r\nh5. Test Case\r\n# Start the app\r\n# Start scrolling the ListView\r\n{code}\r\nvar win = Titanium.UI.createWindow();\r\nvar sections = [];\r\nvar listView = Ti.UI.createListView();\r\nvar section = Ti.UI.createListSection();\r\n\r\n//Same result with this\r\n//section.setItems([]);\r\n\r\nsections.push(section);\r\n\r\nlistView.sections = sections;\r\n\r\nlistView.addEventListener('scrollstart', function(e) {\r\n\tconsole.log(e);\r\n});\r\n\r\nwin.add(listView);\r\nwin.open();\r\n{code}\r\n\r\nh5. Console Log\r\n{code}\r\n[ERROR] : The application has crashed with an uncaught exception 'NSRangeException'.\r\n[ERROR] : Reason:\r\n[ERROR] : *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array\r\n[ERROR] : Stack trace:\r\n[ERROR] : \r\n[ERROR] : 0 CoreFoundation 0x22f205f7 + 126\r\n[ERROR] : 1 libobjc.A.dylib 0x30beac77 objc_exception_throw + 38\r\n[ERROR] : 2 CoreFoundation 0x22e34157 + 230\r\n[ERROR] : 3 ListViewScrollTest 0x0023e4f7 ListViewScrollTest + 1361143\r\n[ERROR] : 4 ListViewScrollTest 0x0023e9eb ListViewScrollTest + 1362411\r\n[ERROR] : 5 ListViewScrollTest 0x0023ea6d ListViewScrollTest + 1362541\r\n[ERROR] : 6 UIKit 0x26554c51 + 280\r\n[ERROR] : 7 UIKit 0x265421af + 294\r\n[ERROR] : 8 UIKit 0x263f0c9d + 668\r\n[ERROR] : 9 UIKit 0x26805a91 + 48\r\n[ERROR] : 10 UIKit 0x263ba515 + 216\r\n[ERROR] : 11 UIKit 0x263b848f + 2950\r\n[ERROR] : 12 CoreFoundation 0x22ee7015 + 20\r\n[ERROR] : 13 CoreFoundation 0x22ee46f9 + 276\r\n[ERROR] : 14 CoreFoundation 0x22ee4afb + 914\r\n[ERROR] : 15 CoreFoundation 0x22e31b31 CFRunLoopRunSpecific + 476\r\n[ERROR] : 16 CoreFoundation 0x22e31943 CFRunLoopRunInMode + 106\r\n[ERROR] : 17 GraphicsServices 0x2a1f5051 GSEventRunModal + 136\r\n[ERROR] : 18 UIKit 0x26423f21 UIApplicationMain + 1440\r\n[ERROR] : 19 ListViewScrollTest 0x000f8a9f ListViewScrollTest + 27295\r\n[ERROR] : 20 libdyld.dylib 0x31186aaf + 2\r\n[ERROR] : *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'\r\n[ERROR] : *** First throw call stack:\r\n[ERROR] : (0x22f205f7 0x30beac77 0x22e34157 0x23e4f7 0x23e9eb 0x23ea6d 0x26554c51 0x265421af 0x263f0c9d 0x26805a91 0x263ba515 0x263b848f 0x22ee7015 0x22ee46f9 0x22ee4afb 0x22e31b31 0x22e31943 0x2a1f5051 0x26423f21 0xf8a9f 0x31186aaf)\r\n{code}\r\n\r\nh5. Possible reason\r\nIn the {{fireScrollEvent}} method of the TiUIListView class there is no check if the array is empty:\r\n{code}\r\n NSArray* indexPaths = [tableView indexPathsForVisibleRows];\r\n NSIndexPath *indexPath = [self pathForSearchPath:[indexPaths objectAtIndex:0]];\r\n{code} ", "attachment": [], "flagged": false, "summary": "iOS: Empty ListView crashes with NSRangeException in 'scrollstart'", "creator": { "name": "c.waldmann@yatego.com", "key": "c.waldmann@yatego.com", "displayName": "Christian Waldmann", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "c.waldmann@yatego.com", "key": "c.waldmann@yatego.com", "displayName": "Christian Waldmann", "active": true, "timeZone": "Europe/Berlin" }, "environment": "4.1.0.GA", "closedSprints": [ { "id": 464, "state": "closed", "name": "2015 Sprint 17 SDK", "startDate": "2015-08-15T00:30:59.243Z", "endDate": "2015-08-29T00:30:00.000Z", "completeDate": "2015-08-31T08:10:47.969Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "358150", "author": { "name": "c.waldmann@yatego.com", "key": "c.waldmann@yatego.com", "displayName": "Christian Waldmann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Pull request: https://github.com/appcelerator/titanium_mobile/pull/6981", "updateAuthor": { "name": "c.waldmann@yatego.com", "key": "c.waldmann@yatego.com", "displayName": "Christian Waldmann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-07-22T12:03:20.000+0000", "updated": "2015-07-22T12:03:20.000+0000" }, { "id": "360336", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR (cherry-picked [~c.waldmann@yatego.com]'s commit): https://github.com/appcelerator/titanium_mobile/pull/7046", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-08-19T10:03:33.000+0000", "updated": "2015-08-19T10:03:33.000+0000" }, { "id": "360337", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR tested and merged.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-08-19T10:04:19.000+0000", "updated": "2015-08-19T10:04:19.000+0000" }, { "id": "364122", "author": { "name": "ncook", "key": "ncook", "displayName": "Nathan Cook", "active": true, "timeZone": "Europe/London" }, "body": "Fix verified, having an empty list view no longer no longer causes a crash.\r\n\r\nTested with:\r\nTitanium SDK: 5.0.0.v20150915230722\r\niOS (8.3, 8.4, 9.0gm)", "updateAuthor": { "name": "ncook", "key": "ncook", "displayName": "Nathan Cook", "active": true, "timeZone": "Europe/London" }, "created": "2015-09-16T22:03:51.000+0000", "updated": "2015-09-16T22:03:51.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }