Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17141] iOS: Application crashes during a numeric search on a ListView

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2014-09-22T20:53:12.000+0000
Affected Version/sRelease 3.2.3
Fix Version/sRelease 3.4.0, Release 3.5.0
ComponentsiOS
Labelscrash, ios, listview, searchbar
ReporterRoberto Zaratin
AssigneeVishal Duggal
Created2014-05-23T10:58:03.000+0000
Updated2014-11-21T20:31:40.000+0000

Description

Problem

if you change the position of the listView during a search the app crashes

Reproduction

Drop the following in an app.js. 1) Run it 2) put 555 in the textField and do a search 3) press the button ("change top of listview") twice and it will crash. (values like 555 or 100 crash the application) warning!: we noticed that if the searched values are less than the listview's height the application will crash. As a matter of fact, if we put values like '78' or '0' the application does not crash.
var win = Ti.UI.createWindow({});

var search = Ti.UI.createSearchBar({});

var items = [];
for (var i = 0; i<1000; i++) {
	items.push({
		properties: {
			title: 'item: ' + i,
			searchableText: 'item: ' + i
		}
	});
}

var button = Ti.UI.createButton({
	title : 'Change top of listView',
	top:50,
});

button.addEventListener('click', function() {
	listView.top === 100 ? listView.top = 150 : listView.top = 100;
});

var listView = Titanium.UI.createListView({
	top: 100,
	sections: [ Ti.UI.createListSection({items: items}) ],
	searchView: search,
});

win.add(button);
win.add(listView);

win.open();

Console Log

[ERROR] :  The application has crashed with an uncaught exception 'NSRangeException'.
[ERROR] :  Reason:
[ERROR] :  *** -[__NSArrayM objectAtIndex:]: index 19 beyond bounds [0 .. 0]
[ERROR] :  Stack trace:
[ERROR] :  0   CoreFoundation                      0x044081c8 __exceptionPreprocess + 152
[ERROR] :  1   libobjc.A.dylib                     0x040c48e5 objc_exception_throw + 44
[ERROR] :  2   CoreFoundation                      0x043a93f6 -[__NSArrayM objectAtIndex:] + 246
[ERROR] :  3   test                                0x00291768 -[TiUIListView pathForSearchPath:] + 184
[ERROR] :  4   test                                0x00297b19 -[TiUIListView tableView:cellForRowAtIndexPath:] + 73
[ERROR] :  5   UIKit                               0x00ade11f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
[ERROR] :  6   UIKit                               0x00ade1f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
[ERROR] :  7   UIKit                               0x00abfece -[UITableView _updateVisibleCellsNow:] + 2428
[ERROR] :  8   UIKit                               0x00ad46a5 -[UITableView layoutSubviews] + 213
[ERROR] :  9   UIKit                               0x00a54964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
[ERROR] :  10  libobjc.A.dylib                     0x040d682b -[NSObject performSelector:withObject:] + 70
[ERROR] :  11  QuartzCore                          0x0301a45a -[CALayer layoutSublayers] + 148
[ERROR] :  12  QuartzCore                          0x0300e244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
[ERROR] :  13  QuartzCore                          0x0300e0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
[ERROR] :  14  QuartzCore                          0x02f747fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
[ERROR] :  15  QuartzCore                          0x02f75b85 _ZN2CA11Transaction6commitEv + 393
[ERROR] :  16  QuartzCore                          0x02f76258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
[ERROR] :  17  CoreFoundation                      0x043d036e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
[ERROR] :  18  CoreFoundation                      0x043d02bf __CFRunLoopDoObservers + 399
[ERROR] :  19  CoreFoundation                      0x043ae254 __CFRunLoopRun + 1076
[ERROR] :  20  CoreFoundation                      0x043ad9d3 CFRunLoopRunSpecific + 467
[ERROR] :  21  CoreFoundation                      0x043ad7eb CFRunLoopRunInMode + 123
[ERROR] :  22  GraphicsServices                    0x05e795ee GSEventRunModal + 192
[ERROR] :  23  GraphicsServices                    0x05e7942b GSEventRun + 104
[ERROR] :  24  UIKit                               0x009e5f9b UIApplicationMain + 1225
[ERROR] :  25  test                                0x00005a58 main + 456
[ERROR] :  26  libdyld.dylib                       0x04a3b701 start + 1
[ERROR] :  2014-05-23 11:46:27.329 test[85362:70b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 19 beyond bounds [0 .. 0]'
[ERROR] :  *** First throw call stack:
[ERROR] :  (
[ERROR] :  	0   CoreFoundation                      0x044081e4 __exceptionPreprocess + 180
[ERROR] :  	1   libobjc.A.dylib                     0x040c48e5 objc_exception_throw + 44
[ERROR] :  	2   CoreFoundation                      0x043a93f6 -[__NSArrayM objectAtIndex:] + 246
[ERROR] :  	3   test                                0x00291768 -[TiUIListView pathForSearchPath:] + 184
[ERROR] :  	4   test                                0x00297b19 -[TiUIListView tableView:cellForRowAtIndexPath:] + 73
[ERROR] :  	5   UIKit                               0x00ade11f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
[ERROR] :  	6   UIKit                               0x00ade1f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
[ERROR] :  	7   UIKit                               0x00abfece -[UITableView _updateVisibleCellsNow:] + 2428
[ERROR] :  	8   UIKit                               0x00ad46a5 -[UITableView layoutSubviews] + 213
[ERROR] :  	9   UIKit                               0x00a54964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
[ERROR] :  	10  libobjc.A.dylib                     0x040d682b -[NSObject performSelector:withObject:] + 70
[ERROR] :  	11  QuartzCore                          0x0301a45a -[CALayer layoutSublayers] + 148
[ERROR] :  	12  QuartzCore                          0x0300e244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
[ERROR] :  	13  QuartzCore                          0x0300e0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
[ERROR] :  	14  QuartzCore                          0x02f747fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
[ERROR] :  	15  QuartzCore                          0x02f75b85 _ZN2CA11Transaction6commitEv + 393
[ERROR] :  	16  QuartzCore                          0x02f76258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
[ERROR] :  	17  CoreFoundation                      0x043d036e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
[ERROR] :  	18  CoreFoundation                      0x043d02bf __CFRunLoopDoObservers + 399
[ERROR] :  	19  CoreFoundation                      0x043ae254 __CFRunLoopRun + 1076
[ERROR] :  	20  CoreFoundation                      0x043ad9d3 CFRunLoopRunSpecific + 467
[ERROR] :  	21  CoreFoundation                      0x043ad7eb CFRunLoopRunInMode + 123
[ERROR] :  	22  GraphicsServices                    0x05e795ee GSEventRunModal + 192
[ERROR] :  	23  GraphicsServices                    0x05e7942b GSEventRun + 104
[ERROR] :  	24  UIKit                               0x009e5f9b UIApplicationMain + 1225
[ERROR] :  	25  test                                0x00005a58 main + 456
[ERROR] :  	26  libdyld.dylib                       0x04a3b701 start + 1
[ERROR] :  )
[ERROR] :  libc++abi.dylib: terminating with uncaught exception of type NSException

Comments

  1. Ritu Agrawal 2014-05-23

    I followed the exact same steps provided by you and tried to reproduce the issue on iPhone 5S but was not able to reproduce it. Are you seeing this error on a particular device?
  2. Roberto Zaratin 2014-05-26

    please test again the code, we added better explanation
  3. Pier Paolo Ramon 2014-06-11

    This issues is preventing us from porting an old TableView-based layout to a more performant ListView. [~ragrawal], could you have a look on it?
  4. Ritu Agrawal 2014-06-11

    Moving this to engineering as I can reproduce the issue with the provided test case and steps for further evaluation and prioritization.
  5. Shameer Jan 2014-08-27

    Issue still exists with SDK Version 3.2.3 and 3.4.0 Titanium Command-Line Interface, CLI version 3.3.0, Titanium SDK version 3.2.3.GA Titanium SDK version 3.4.0.GA Appcelerator Studio, build: 3.3.0.201407111535 iOS SDK: 7.1 iOS iPhone Simulator: 7.1
  6. Pedro Enrique 2014-09-22

    PR https://github.com/appcelerator/titanium_mobile/pull/6152 (master) PR https://github.com/appcelerator/titanium_mobile/pull/6153 (3.4.x) MERGED
  7. Olga Romero 2014-09-23

    Tested and verified no crashes, using Mac osx 10.9.5 Mavericks Appcelerator Studio, build: 3.4.0.201409161950 Titanium SDK, build: 3.4.0.v20140922135716 acs@1.0.16 alloy 1.5.0-rc2 install@0.1.7 npm@1.4.23 sudo@1.0.3 titanium 3.4.0-rc4 titanium-code-processor@1.1.1 Xcode6.0.1 (6A317) Devices: iPhone 6 iOS 8 iPhone 6+ iOS 8 Closing as fixed.

JSON Source