Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2910] iOS / iPad: setData in anything post 1.4.x flickers

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T02:00:25.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M08
ComponentsiOS
Labelsios, quickstart-customer, regression, release-1.6.0, rplist, tableview
ReporterRick Blalock
AssigneeRalf Pfeiffer
Created2011-04-15T03:32:39.000+0000
Updated2011-04-17T02:00:25.000+0000

Description

setData() sometimes performs strange when using it in conjunction with a window focus event.

There have been a few reports of flickering and other odd behaviors on the q/a forums, i.e.:
http://developer.appcelerator.com/question/91471/updating-table-on-window-focus"> http://developer.appcelerator.com/question/91471/updating-table-on-...
http://developer.appcelerator.com/question/92611/tableview-rendering-async-since-150"> http://developer.appcelerator.com/question/92611/tableview-renderin...

In the specific case of a quickstart customer I am assisting, table row contents flicker when setData is called on a window focus event. Attached is a video to show you what it is doing.

His code is fairly abstracted out but here are some examples of his code: http://pastie.org/1485195">http://pastie.org/1485195

Most of his custom methods for creating rows, etc. are just wrappers for native Ti code. Nothing magical going on in the background - just stuff to help him manage the app. I can provide that if you need it.


Using the sample code below - on the sim the label positioned on the right hand side jumps over to the right - http://screencast.com/t/nsqmRxa37Z">http://screencast.com/t/nsqmRxa37Z. On the device this does not happen but a black area flickers for a short bit. (see attached video)

Below is some sample code to run. It doesn't duplicate some of the issues exactly but does still show a few oddities (in both the sim and device) as mentioned above:

var win = Titanium.UI.currentWindow;

var rows = [];

var tableview = Ti.UI.createTableView();

for (var i=0; i < 10; i++) {
    var row = Ti.UI.createTableViewRow({
        left: 0,
        top: 0,
        height: 50, 
        width: '100%',
        separatorStyle: Ti.UI.iPhone.TableViewSeparatorStyle.NONE, 
        backgroundColor: 'transparent', 
        color: 'Red',
        selectedBackgroundImage: ''
    });
    
    var label = Ti.UI.createLabel({top: 10, left: 10, height: 22, width: 100, color: '#444', text: 'sometext', font: {fontFamily: 'Helvetica Neue', fontSize:20, fontWeight:'bold'}, textAlign: 'left'});
    
    var label2 = Ti.UI.createLabel({top: 10, right: 10, height: 22, width: 100, color: '#444', text: 'sometext', font: {fontFamily: 'Helvetica Neue', fontSize:20, fontWeight:'bold'}, textAlign: 'left'});
    
    row.add(label);
    row.add(label2);
    
    rows.push(row);
};

var button = Ti.UI.createButton({
    title: "setData",
    width: 50,
    height: 50,
    top: 10,
    right: 10
});

win.addEventListener('focus', function() {
    setTimeout(function() {
        tableview.setData(rows);
    }, 1000);
});

button.addEventListener('click', function() {
    tableview.setData(rows);
});

tableview.addEventListener('click', function() {
    var newwin = Ti.UI.createWindow({
        title: 'New window',
        url: 'test.js'
    });
    Ti.UI.currentTab.open(newwin, { animated: true });
});

win.add(tableview);
win.add(button);

Attachments

FileDateSize
img_0587.MOV2011-04-15T03:32:40.000+00001791536
img_0588.MOV2011-04-15T03:32:39.000+00001395523

Comments

  1. Blain Hamon 2011-04-15

    Having problems trying to recreate this. Some of this may be due to fixes that have happened since the bug was logged.

  2. Rick Blalock 2011-04-15

    This hasn't been an issue since early last week in the latest builds. I actually thought you fixed this since it was working last week.

  3. Blain Hamon 2011-04-15

    Hunh. I figured it might have been the case, but knowing how bugs can be interrelated or have common roots, I didn't have this bug in mind when fixing the others. If the issue has gone away for you, shall we call this one fixed-in-qa?

  4. Rick Blalock 2011-04-15

    Yes I think that's safe to do. I haven't tested with the build today but it worked all week last week. I suppose it'd be good to know that fixed it to avoid regression issues.

  5. Brian 2011-04-15

    This still doesn't work in 1.6.1...whenever you call setData on a tableView...the entire table flickers really bad. On an iPhone 3G it's even worse. The workaround everyone is using is the following:

    tableView.hide();
    tableView.setData(data);
    setTimeout(function() {
    tableView.show(); },50);

    But unfortunately this workaround won't work for my app....please re-open this bug. It's a really ugly one that seems to have around for a while now.

  6. Brian 2011-04-15

    I created a new ticket that has a better example of the issue:

    https://appcelerator.lighthouseapp.com/projects/32238/tickets/3407-tableview-with-dynamic-row-height-causes-really-bad-flickering"> https://appcelerator.lighthouseapp.com/projects/32238/tickets/3407-...

JSON Source