[TIMOB-26164] iOS: TableView + run-on-main-thread - insertRowAfter directly after updateRow causes error / race crash
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-08-24T17:23:49.000+0000 |
Affected Version/s | Release 7.1.1, Release 7.2.0 |
Fix Version/s | Release 7.5.0 |
Components | iOS |
Labels | alloy, run-on-main-thread, tableview, tableviewrow, titanium |
Reporter | David van de Meer |
Assignee | Vijay Singh |
Created | 2018-06-28T07:21:11.000+0000 |
Updated | 2018-08-24T17:23:57.000+0000 |
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();
Test Case -
PR : https://github.com/appcelerator/titanium_mobile/pull/10140
Confirmed working on my patched SDK
*Closing ticket*, Verified fix in SDK Version:
7.4.0.v20180717131401
*FR Passed (Test Steps):*Created a titanium Application
Added the following code above in to the
app.js
Ran the program
Pressed "Update + Add"
Application no longer crashes un like in 7.2.0.GA
*Test Environment*