Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12637] iOS: TableView poor performance due to relayouts

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-03-25T09:28:55.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.0.2
ComponentsiOS
Labelsios, layout, performance, tableview
Reportererez pilosof
Assigneejithinpv
Created2012-10-03T17:12:27.000+0000
Updated2017-03-21T22:16:00.000+0000

Description

*Problem description* There is a lot of unnecessary relayouts when using complex rows with labels and images, leading to poor performance. *Test case*
var win = Ti.UI.createWindow({});
var table = Ti.UI.createTableView({});
win.add(table);
win.addEventListener("open", function() {
	var data = [];

	for ( i = 0; i < 10; i++) {
		(function(i) {
			var row = Ti.UI.createTableViewRow({
				width : 320,
				height : 200
			});
			row.addEventListener("postlayout", function() {
				Ti.API.info("row:" + i)
			});

			var bimg = Ti.UI.createImageView({
				image : 'http://overtheair.org/blog/wp-content/uploads/2011/09/appcelerator-logo.png',
				top : 25,
				left : 0,
				right : 0,
				bottom : 5
			});
			bimg.addEventListener("postlayout", function() {
				Ti.API.info("bimg:" + i)
			});

			var simg = Ti.UI.createImageView({
				image : 'http://overtheair.org/blog/wp-content/uploads/2011/09/appcelerator-logo.png',
				top : 25,
				left : 5,
				width : 30,
				height : 30
			});
			simg.addEventListener("postlayout", function() {
				Ti.API.info("simg:" + i)
			});

			var bview = Ti.UI.createView({
				top : 0,
				left : 0,
				width : 100,
				height : 20
			});
			bview.addEventListener("postlayout", function() {
				Ti.API.info("bview:" + i)
			});

			var label = Ti.UI.createLabel({
				text : "row:" + i,
				top : 5,
				left : 5,
				right : 5,
				bottom : 5,
				height : Ti.UI.SIZE
			});
			label.addEventListener("postlayout", function() {
				Ti.API.info("label:" + i)
			});

			row.add(bimg);
			row.add(simg);
			bview.add(label);
			row.add(bview);

			row.className = "testrow";
			data.push(row);
		})(i);
	}
	table.setData(data);
})

win.open();

Comments

  1. jithinpv 2013-03-25

    Issue does not 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) iOS iPhone Simulator: iOS SDK version: 6.0 jithinpv
  2. jithinpv 2013-06-20

    Issue does not reproduces Tested with iOS SDK: 5.1 iOS iPhone Simulator: 5.1 Mac OS X Version 10.7.5 Titanium SDK version 3.1.1.v20130606121419 Titanium Studio, build: 3.0.1.201212181159
  3. Lee Morris 2017-03-21

    Closing ticket as the issue cannot be reproduced and due to the above comments.

JSON Source