Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8699] Android: TableView "appendRow" function is slow when called for each row

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-10T18:05:13.000+0000
Affected Version/sRelease 3.1.0
Fix Version/sn/a
ComponentsAndroid
Labelsapi
ReporterIvan Skugor
AssigneeUnknown
Created2012-04-12T02:55:17.000+0000
Updated2020-01-10T18:05:13.000+0000

Description

The problem

TableView's "appendRow" method seems to be very slow when rows are appended one by one. Performance issue does not exists if that method is called on array of rows.

Steps to reproduce this issue

Run this example:
var win1 = Titanium.UI.createWindow({
    title:'Form Test',
    navBarHidden: true,
    backgroundColor:'#eee'
});

var tableView = Ti.UI.createTableView({
    
});

var rows = [];

var start = new Date();

for (var i = 0; i < 100; ++i) {
    
    var row = Ti.UI.createTableViewRow({ title: 'Row ' + i, className: 'Row' });
    
    tableView.appendRow(row);
}

Ti.API.info(new Date() - start);

win1.add(tableView);

win1.open();
And see the output. On a device that I'm testing on, I'm getting around 5000ms.

Expected behavior

Above example really should not run that long. 100 rows is not that big number and 5 seconds is just too slow. If array of rows is used, then performance is much better (same as using "setData") as can be seen in this test case:
var win1 = Titanium.UI.createWindow({
    title:'Form Test',
    navBarHidden: true,
    backgroundColor:'#eee'
});

var tableView = Ti.UI.createTableView({
    
});

var rows = [];

var start = new Date();

for (var i = 0; i < 100; ++i) {
    
    var row = Ti.UI.createTableViewRow({ title: 'Row ' + i, className: 'Row' });
    
    rows.push(row);
    
}

tableView.appendRow(rows);

Ti.API.info(new Date() - start);

win1.add(tableView);

win1.open();
In this case, test completes in about 200ms and is similar to "setData" performance. In my opinion, performances in both cases should be similar.

Comments

  1. Ivan Skugor 2012-04-19

    Hello. I see that this ticket was mentioned in the Wiki: https://wiki.appcelerator.org/display/guides/TableViews To explain why did I make this ticket. No one normal will append 100 rows. And if 100 rows needs to be appended to the table view, an array of rows can be created first and then passed to "appendRow" function. I'm not trying to say I am not normal :D 100 rows is big enough number to see the performance drop clearly and "appendRow", as its name says, accepts one row. Support for array of rows was added recently. Anyway, this function is extremely useful when building native JS wrapper for TableView component. Wrapper for TableView is tricky to implement and "appendRow" makes that task very easy to do. That's why performance of this function is important when it's called as I described. This can be set "low" priority because there are only few devs that are trying to build native wrappers around Titanium components (Kevin and me, and there was few others but they are not active any more) and there are even fewer devs that are trying to wrap TableView. No matter that, I would like to see this ticket resolved because I think that native-like behavior of JS host objects is awesome in any JS environment and in Titanium especially (and resolving this ticket would help that purpose).
  2. jithinpv 2013-03-19

    When using append row it takes more time to launch the app, but if we use the second sample code it works faster. Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4 jithinpv
  3. Alan Hutton 2020-01-10

    This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.

JSON Source