[TIMOB-25586] iOS: Crash when selecting filtered row in Ti.UI.SearchBar
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-12-15T21:09:35.000+0000 |
Affected Version/s | Release 6.3.0 |
Fix Version/s | Release 7.0.1 |
Components | iOS |
Labels | filtered, row, searchBar |
Reporter | Michael Landeck |
Assignee | Vijay Singh |
Created | 2017-12-05T09:40:56.000+0000 |
Updated | 2018-08-06T17:49:29.000+0000 |
Description
Hi, i have a problem with selecting a filtered row in a tableview.
The app crashes, when i try to change the background color of the clicked row.
This happens only when in tiapp.xml run-on-main-thread is set to true.
Example (Just click on a filtered row):
Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow();
var view = Titanium.UI.createView({
top:30,
width:400,
left:150,
});
var oldRow;
var tableData = [ {title: 'Apples'}, {title: 'Bananas'}, {title: 'Carrots'}, {title: 'Potatoes'} ];
var searchBar = Titanium.UI.createSearchBar({
showCancel:true,
});
var table = Ti.UI.createTableView({
data: tableData,
search:searchBar,
width:300,
hideSearchOnSelection:false
});
table.addEventListener('click', function(e) {
if (oldRow != null)
oldRow.backgroundColor = 'white';
e.row.backgroundColor = '#E6E6E6';
oldRow = e.row;
});
view.add(table);
win.add(view);
win.open();
[ERROR] : The application has crashed with an uncaught exception 'NSInternalInconsistencyException'.
[ERROR] : Reason:
[ERROR] : attempt to insert row 3 into section 0, but there are only 2 rows in section 0 after the update
[ERROR] : Stack trace:
[ERROR] : 0 CoreFoundation 0x0000000114653193 __exceptionPreprocess + 147
[ERROR] : 1 libobjc.A.dylib 0x0000000113720f41 objc_exception_throw + 48
[ERROR] : 2 CoreFoundation 0x0000000114658372 +[NSException raise:format:arguments:] + 98
[ERROR] : 3 Foundation 0x000000010df8c089 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
[ERROR] : 4 UIKit 0x000000010e62ded7 -[UITableView _endCellAnimationsWithContext:] + 9203
[ERROR] : 5 UIKit 0x000000010e64c2e4 -[UITableView _updateRowsAtIndexPaths:withUpdateAction:rowAnimation:usingPresentationValues:] + 1342
[ERROR] : 6 UIKit 0x000000010e64c69d -[UITableView reloadRowsAtIndexPaths:withRowAnimation:] + 133
[ERROR] : 7 test 0x000000010c460463 -[TiUITableView dispatchAction:] + 771
[ERROR] : 8 test 0x000000010c520341 -[TiUITableViewRowProxy updateRow:] + 97
[ERROR] : 9 test 0x000000010c5204da __41-[TiUITableViewRowProxy triggerRowUpdate]_block_invoke + 42
[ERROR] : 10 libdispatch.dylib 0x00000001178f7273 _dispatch_call_block_and_release + 12
[ERROR] : 11 libdispatch.dylib 0x00000001178f82b5 _dispatch_client_callout + 8
[ERROR] : 12 libdispatch.dylib 0x0000000117902496 _dispatch_main_queue_callback_4CF + 1260
[ERROR] : 13 CoreFoundation 0x0000000114615ee9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
[ERROR] : 14 CoreFoundation 0x00000001145da592 __CFRunLoopRun + 2402
[ERROR] : 15 CoreFoundation 0x00000001145d99b9 CFRunLoopRunSpecific + 409
[ERROR] : 16 GraphicsServices 0x00000001163d09c6 GSEventRunModal + 62
[ERROR] : 17 UIKit 0x000000010e50d5e8 UIApplicationMain + 159
[ERROR] : 18 test 0x000000010c3bed54 main + 100
[ERROR] : 19 libdyld.dylib 0x000000011796cd81 start + 1
[ERROR] : 20 ??? 0x0000000000000001 0x0 + 1
-- End simulator log ---------------------------------------------------------
Hello, I wasn't able to reproduce the issue with the sample code you have provided. I Run on SDK 6.3.0.GA and setting run on the main thread to true in tiapp.xml. I don't see the crash happening when I click on a table view row. The selected row background color does change. I am sending a screenshot of that [screenshot](https://ibb.co/mZocCw). Thanks.
Sharif, please type something into the searchbar to filter the rows, clicking on a filtered row causes the error. Thank you
We changed the underlaying API of the SearchBar API in 6.3.0, but some cases have not made it into the GA. Those are included in 7.0.0 which will be published this week. You can try out the final version already using
appc ti sdk install -b 7_0_X
. We will still validate if it fixes your issue as well and provide a PR if it doesn't.Test Case (Other than mentioned in ticket): PR (master) : https://github.com/appcelerator/titanium_mobile/pull/9677
[~vijaysingh] Can you please do a 7_0_X backport as well? Also, could this be an issue for Ti.UI.ListView as well?
PR (7_0_X) : https://github.com/appcelerator/titanium_mobile/pull/9680
FR Passed. Crash no longer occurs when selecting a filtered row. Verified on both tableView and listView
Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.