Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25586] iOS: Crash when selecting filtered row in Ti.UI.SearchBar

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-12-15T21:09:35.000+0000
Affected Version/sRelease 6.3.0
Fix Version/sRelease 7.0.1
ComponentsiOS
Labelsfiltered, row, searchBar
ReporterMichael Landeck
AssigneeVijay Singh
Created2017-12-05T09:40:56.000+0000
Updated2018-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 ---------------------------------------------------------

Comments

  1. Sharif AbuDarda 2017-12-05

    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.
  2. Michael Landeck 2017-12-06

    Sharif, please type something into the searchbar to filter the rows, clicking on a filtered row causes the error. Thank you
  3. Hans Knöchel 2017-12-07

    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.
  4. Vijay Singh 2017-12-12

    Test Case (Other than mentioned in ticket): PR (master) : https://github.com/appcelerator/titanium_mobile/pull/9677
       Ti.UI.backgroundColor = 'white';
       var win = Ti.UI.createWindow();
       var view = Titanium.UI.createView({
           top:30,
           width:400,
           left:10,
       });
       var oldRow;
       var tableData = [ {title: 'Change Row Height to 100'}, {title: 'Change Row Color to Blue'}, {title: 'Delete Row'}, 
       {title: 'Insert Row Before This Row'}, {title: 'Insert Row After This Row'}, {title : 'Update This Row'}, 
       {title : 'Append Row'}, {title : 'Set New Data to TableView'}];
       
       var sectionUpdate = Ti.UI.createTableViewSection({ headerTitle: 'Update Rows proeprties' });
       sectionUpdate.add(Ti.UI.createTableViewRow({ title: 'Change Row Height to 100' }));
       sectionUpdate.add(Ti.UI.createTableViewRow({ title: 'Change Row Color to Blue' }));
       
       var sectionInsert = Ti.UI.createTableViewSection({ headerTitle: 'Insert/Delete rows' });
       sectionInsert.add(Ti.UI.createTableViewRow({ title: 'Delete Row' }));
       sectionInsert.add(Ti.UI.createTableViewRow({ title: 'Insert Row Before This Row' }));
       
       var tableDataNew = [sectionUpdate, sectionInsert];
       
       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 (e.row.title == 'Change Row Height to 100') {
           e.row.setHeight(100);
         } else if (e.row.title == 'Change Row Color to Blue') {
           e.row.backgroundColor = 'blue';
         } else if (e.row.title == 'Delete Row') {
           table.deleteRow(e.row);
         } else if (e.row.title == 'Insert Row Before This Row') {
           var row = Ti.UI.createTableViewRow({title : 'Row Inserted Before'});
           table.insertRowBefore(e.index, row);
         } else if (e.row.title == 'Insert Row After This Row') {
           var row = Ti.UI.createTableViewRow({title : 'Row Inserted After'});
           table.insertRowAfter(e.index, row);
         } else if (e.row.title == 'Update This Row') {
           var row = Ti.UI.createTableViewRow({title : 'Updated Row'});
           table.updateRow(e.index, row);
         } else if (e.row.title == 'Append Row') {
           var row = Ti.UI.createTableViewRow({title : 'Appended Row'});
           table.appendRow(row);
         } else if (e.row.title == 'Set New Data to TableView') {
           table.setData(tableDataNew);
         } 
       }); 
       view.add(table);
       win.add(view);
       win.open();
       
  5. Hans Knöchel 2017-12-12

    [~vijaysingh] Can you please do a 7_0_X backport as well? Also, could this be an issue for Ti.UI.ListView as well?
  6. Vijay Singh 2017-12-13

    PR (7_0_X) : https://github.com/appcelerator/titanium_mobile/pull/9680
  7. Eric Wieber 2017-12-14

    FR Passed. Crash no longer occurs when selecting a filtered row. Verified on both tableView and listView
  8. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source