Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26164

iOS: TableView + run-on-main-thread - insertRowAfter directly after updateRow causes error / race crash

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 7.1.1, Release 7.2.0
    • Fix Version/s: Release 7.5.0
    • Component/s: iOS
    • Environment:
    • Story Points:
      0
    • Sprint:
      2016 Sprint 17 SDK

      Description

      When enabling

      <property name="run-on-main-thread" type="bool">true</property>
      

      and using TableView, if one runs insertRowAfter directly after updateRow the app will throw the error below or cause race crash with no error.

      Error:

      [ERROR] Script Error {
      [ERROR]     column = 27;
      [ERROR]     line = 90;
      [ERROR]     message = "Invalid update: invalid number of rows in section 0.  The number of rows contained in an existing section after the update (20) must be equal to the number of rows contained in that section before the update (20), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).";
      

      Steps to reproduce:
      1. Create new alloy project
      2. In your index.js add the code below
      3. Build to ios simlulator
      5. Click on "Update + Add" button
      7. Remove run-on-main-thread from tiapp.xml and build and see that everything works fine.

      PS....when adding the setTimeout you will see that it works

      var rowData = [];
       
      for (var i=0; i<20; i++){
       
      	var row = Ti.UI.createTableViewRow({
      	    height: "50dp",
      	    width:	Ti.UI.FILL,
      	    title: "row" + i,
      	});	
       
      	rowData.push(row);
       
      };
       
      var tableView = Ti.UI.createTableView({
        	data:rowData,
        	bottom: 50,
      });
       
      $.index.add(tableView);
       
      var button = Titanium.UI.createButton({
      	title: 'Update + Add',
      	bottom: 10,
      	height: 50,
      });
       
      button.addEventListener('click',function(){
      		
      	var updatedRow = Ti.UI.createTableViewRow({
      	    height: "50dp",
      	    width:	Ti.UI.FILL,
      	    title: "updatedRow",
      	});
      	tableView.updateRow(0,updatedRow);
      		
      	//setTimeout(function(){ // uncomment to see it working with a delay
      	var newRow = Ti.UI.createTableViewRow({
      	    height: '50dp',
      	    width:	Ti.UI.FILL,
      	    title: "newRow",
      	});
      	tableView.insertRowAfter(0,newRow);
      	//}, 500);
      });
       
      $.index.add(button);
      	  
      $.index.open();
      

        Attachments

          Activity

            People

            • Assignee:
              vijaysingh Vijay Singh
              Reporter:
              dieskim David van de Meer
              Reviewer:
              Hans Knöchel
              Tester:
              Samir Mohammed
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-6426
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code