[TIMOB-24067] iOS: List view crash when deleting rows with "pruneSectionsOnEdit" set
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-03-09T19:19:58.000+0000 |
Affected Version/s | Release 5.5.1 |
Fix Version/s | Release 6.1.0 |
Components | iOS |
Labels | qe-6.1.0 |
Reporter | Ivan Skugor |
Assignee | Vijay Singh |
Created | 2016-10-24T11:32:52.000+0000 |
Updated | 2017-03-29T15:08:50.000+0000 |
Description
To see this issue, run this code:
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var myTemplate = {
properties: {
canEdit: true
},
childTemplates: [{
type: 'Ti.UI.Label',
bindId: 'info',
properties: {
color: '#000',
left: 60,
top: 0
}
}]
};
var listView = Ti.UI.createListView({
top: 20,
bottom: 0,
templates: {
'template': myTemplate
},
pruneSectionsOnEdit: true,
defaultItemTemplate: 'template'
});
var sections = [];
var fruitSection = Ti.UI.createListSection({
headerTitle: 'Fruits'
});
var fruitDataSet = [{
info: {
text: 'Apple'
}
}, {
info: {
text: 'Banana'
}
}];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);
listView.setSections(sections);
win.add(listView);
win.open();
Then swipe list view row to left to get "Delete" option. Press "Delete" to delete row.
Delete both rows.
After last row has been deleted, app crashes.
Here's crash log:
[ERROR] The application has crashed with an uncaught exception 'NSInternalInconsistencyException'.
[ERROR] Reason:
[ERROR] attempt to insert section 0 but there are only 0 sections after the update
[ERROR] Stack trace:
[ERROR]
[ERROR] 0 CoreFoundation 0x067d01f0 __exceptionPreprocess + 160
[ERROR] 1 libobjc.A.dylib 0x05e45e66 objc_exception_throw + 52
[ERROR] 2 CoreFoundation 0x067d4332 +[NSException raise:format:arguments:] + 130
[ERROR] 3 Foundation 0x018ce3c4 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 94
[ERROR] 4 UIKit 0x01e52b7b -[UITableView _endCellAnimationsWithContext:] + 11060
[ERROR] 5 UIKit 0x01e6d4bd -[UITableView endUpdatesWithContext:] + 49
[ERROR] 6 UIKit 0x01e6d4e1 -[UITableView endUpdates] + 31
[ERROR] 7 Test2 0x002ea9eb -[TiUIListView tableView:commitEditingStyle:forRowAtIndexPath:] + 1611
[ERROR] 8 UIKit 0x01e897d0 -[UITableView _animateDeletionOfRowWithCell:] + 192
[ERROR] 9 UIKit 0x01e5a4c3 __52-[UITableView _swipeActionButtonsForRowAtIndexPath:]_block_invoke + 99
[ERROR] 10 UIKit 0x01e8aff5 -[UITableView _actionButton:pushedInCell:] + 206
[ERROR] 11 UIKit 0x02128069 -[UITableViewCell _actionButtonPushed:] + 90
[ERROR] 12 libobjc.A.dylib 0x05e5b200 -[NSObject performSelector:withObject:withObject:] + 63
[ERROR] 13 UIKit 0x01cf581e -[UIApplication sendAction:to:from:forEvent:] + 91
[ERROR] 14 UIKit 0x01cf57b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 41
[ERROR] 15 UIKit 0x01ea432b -[UIControl sendAction:to:forEvent:] + 64
[ERROR] 16 UIKit 0x01ea4693 -[UIControl _sendActionsForEvents:withEvent:] + 462
[ERROR] 17 UIKit 0x01ea3518 -[UIControl touchesEnded:withEvent:] + 717
[ERROR] 18 UIKit 0x022a4d8b _UIGestureEnvironmentSortAndSendDelayedTouches + 6131
[ERROR] 19 UIKit 0x0229f32e _UIGestureEnvironmentUpdate + 1539
[ERROR] 20 UIKit 0x0229ece3 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 494
[ERROR] 21 UIKit 0x0229de8d -[UIGestureEnvironment _updateGesturesForEvent:window:] + 259
[ERROR] 22 UIKit 0x01d6d7c3 -[UIWindow sendEvent:] + 4276
[ERROR] 23 UIKit 0x01d14198 -[UIApplication sendEvent:] + 395
[ERROR] 24 UIKit 0x025bb6cd __dispatchPreprocessedEventFromEventQueue + 3706
[ERROR] 25 UIKit 0x025b37af __handleEventQueue + 5345
[ERROR] 26 CoreFoundation 0x0676fcbf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
[ERROR] 27 CoreFoundation 0x06753df7 __CFRunLoopDoSources0 + 519
[ERROR] 28 CoreFoundation 0x06753284 __CFRunLoopRun + 1124
[ERROR] 29 CoreFoundation 0x06752bab CFRunLoopRunSpecific + 395
[ERROR] 30 CoreFoundation 0x06752a0b CFRunLoopRunInMode + 123
[ERROR] 31 GraphicsServices 0x07796b4c GSEventRunModal + 177
[ERROR] 32 GraphicsServices 0x077969c7 GSEventRun + 80
[ERROR] 33 UIKit 0x01cf37fb UIApplicationMain + 148
[ERROR] 34 Test2 0x0000a2e8 main + 408
[ERROR] 35 libdyld.dylib 0x08ceb799 start + 1
[ERROR]
[ERROR] 2016-10-24 13:26:36.594 Test2[73649:6482265] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to insert section 0 but there are only 0 sections after the update'
[ERROR] *** First throw call stack:
[ERROR] (
[ERROR] 0 CoreFoundation 0x067d0212 __exceptionPreprocess + 194
[ERROR] 1 libobjc.A.dylib 0x05e45e66 objc_exception_throw + 52
[ERROR] 2 CoreFoundation 0x067d4332 +[NSException raise:format:arguments:] + 130
[ERROR] 3 Foundation 0x018ce3c4 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 94
[ERROR] 4 UIKit 0x01e52b7b -[UITableView _endCellAnimationsWithContext:] + 11060
[ERROR] 5 UIKit 0x01e6d4bd -[UITableView endUpdatesWithContext:] + 49
[ERROR] 6 UIKit 0x01e6d4e1 -[UITableView endUpdates] + 31
[ERROR] 7 Test2 0x002ea9eb -[TiUIListView tableView:commitEditingStyle:forRowAtIndexPath:] + 1611
[ERROR] 8 UIKit 0x01e897d0 -[UITableView _animateDeletionOfRowWithCell:] + 192
[ERROR] 9 UIKit 0x01e5a4c3 __52-[UITableView _swipeActionButtonsForRowAtIndexPath:]_block_invoke + 99
[ERROR] 10 UIKit 0x01e8aff5 -[UITableView _actionButton:pushedInCell:] + 206
[ERROR] 11 UIKit 0x02128069 -[UITableViewCell _actionButtonPushed:] + 90
[ERROR] 12 libobjc.A.dylib 0x05e5b200 -[NSObject performSelector:withObject:withObject:] + 63
[ERROR] 13 UIKit 0x01cf581e -[UIApplication sendAction:to:from:forEvent:] + 91
[ERROR] 14 UIKit 0x01cf57b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 41
[ERROR] 15 UIKit 0x01ea432b -[UIControl sendAction:to:forEvent:] + 64
[ERROR] 16 UIKit 0x01ea4693 -[UIControl _sendActionsForEvents:withEvent:] + 462
[ERROR] 17 UIKit 0x01ea3518 -[UIControl touchesEnded:withEvent:] + 717
[ERROR] 18 UIKit 0x022a4d8b _UIGestureEnvironmentSortAndSendDelayedTouches + 6131
[ERROR] 19 UIKit 0x0229f32e _UIGestureEnvironmentUpdate + 1539
[ERROR] 20 UIKit 0x0229ece3 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 494
[ERROR] 21 UIKit 0x0229de8d -[UIGestureEnvironment _updateGesturesForEvent:window:] + 259
[ERROR] 22 UIKit 0x01d6d7c3 -[UIWindow sendEvent:] + 4276
[ERROR] 23 UIKit 0x01d14198 -[UIApplication sendEvent:] + 395
[ERROR] 24 UIKit 0x025bb6cd __dispatchPreprocessedEventFromEventQueue + 3706
[ERROR] 25 UIKit 0x025b37af __handleEventQueue + 5345
[ERROR] 26 CoreFoundation 0x0676fcbf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
[ERROR] 27 CoreFoundation 0x06753df7 __CFRunLoopDoSources0 + 519
[ERROR] 28 CoreFoundation 0x06753284 __CFRunLoopRun + 1124
[ERROR] 29 CoreFoundation 0x06752bab CFRunLoopRunSpecific + 395
[ERROR] 30 CoreFoundation 0x06752a0b CFRunLoopRunInMode + 123
[ERROR] 31 GraphicsServices 0x07796b4c GSEventRunModal + 177
[ERROR] 32 GraphicsServices 0x077969c7 GSEventRun + 80
[ERROR] 33 UIKit 0x01cf37fb UIApplicationMain + 148
[ERROR] 34 Test2 0x0000a2e8 main + 408
[ERROR] 35 libdyld.dylib 0x08ceb799 start + 1
[ERROR] )
[ERROR] libc++abi.dylib: terminating with uncaught exception of type NSException
Is this a regression from 5.4.x to 5.5.x?
No, I think it happened with 5.3.0.GA also.
Replacing [this line](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiUIListView.m#L1135) with
[tableView deleteSections:theSet withRowAnimation:UITableViewRowAnimationFade];
fixes the crash, but I'm curious why we used the other method instead. The index in the "delete" event is still correct, but we should investigate this further before doing a PR.PR : https://github.com/appcelerator/titanium_mobile/pull/8870
{noformat} Mac OS Version : 10.12.3 Xcode Version : Xcode 8.2 Build version 8C38 Appc CLI : 6.1.0 Appc NPM : 4.2.9-1 Node : v4.6.0 Device: iPhone 6 (10.2.1) iPhone 5 (9.3.5) {noformat} Using above env passed FR. After merge, the changes are present in SDK
6.1.0.v20170328172120
. *Closing*