Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

why is the cpu going crazy when using tableViewSection.headerView?

hi, I've met this very strange issue which bothers me because it hinders my development. After a long time debugging my project I found a combination of circumstances which causes the following problem:

When I want a tableView with my own custom styled section headers, using the tableViewSection.headerView property with a custom view opened in a new window, the app causes the cpu usage of my (new) macbook pro to increase to 100% indicating some sort of infinite loop or whatever when trying to render. The weird thing is that exactly the same code which causes this issue doesn't cause any problems when I don't use it in a separate .js file which is opened in a new window.

I've stripped down the code which causes the problem to a bare minimum during the debugging and came up with the following:


var win = Ti.UI.currentWindow;
var tableView = Ti.UI.createTableView({
var newData = [];
var row = Titanium.UI.createTableViewRow({});        
var lbl = Titanium.UI.createLabel({
    text: 'this is a test', height:'auto', top:10, left:10, right:10, color:'#000'
row.className = 'test';        
var section = Titanium.UI.createTableViewSection({});
var headerViewRows = Titanium.UI.createView({
    height:30, width:'auto'
var headerLabel = Titanium.UI.createLabel({
    text: 'this is a test header text', height:'auto', top:10, left:10, right:10, color:'#000'
section.headerView = headerViewRows;  // uncommenting this line will cause the cpu to go wayyy up, not using custom headerview will work as expected
section.headerTitle = 'test header title';  
tableView.data = newData;  // no difference between using data = ... or using setData(...

I also tried every variant of properties I could come up with for the headerLabel, and the headerViewRows, all did not change anything. The view can be created without any explicitly set properties and even without the label added, and no properties for the section change anything either.

Now for the issue:
If you create a new project and just use the code above in the 'win1', adding the tableView to the win1 object, everything works correctly.
But if you would use this as a separate file (bug.js), using the 'url' property of a new window opened from the win1 (by adding a click event listener to the label) like this:

app.js (of a newly created default project):

label1.addEventListener('click', function(e){
    var newWin = Ti.UI.createWindow({

… causes the cpu to run to its max and sort of freezes the app. (simulator)

Now for some extra weirdness:
commenting the line which sets the headerView property of the section object will not cause this cpu-overload.

I would really like to know why this happens, what I am doing wrong or how to fix this behaviour.

some extra info for the appcelerator developers:
I also noticed the following: When I add a 'touchend' eventListener to the tableView and log some line in the event, it will output this line infinitely whenever the window is opened, like it is continuously being called.

btw. this is all on the latest 1.4.0 mobilesdk, titanium developer 1.2.1, iphone sdk 4.0 (latest 4.0.1 xcode)

I hope someone can offer some insight into this behaviour, thanks a lot

— asked August 3rd 2010 by Victor van Rijn
  • headerview
  • tableview
  • tableviewsection

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.