Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9322] Android: Adding Label properties after creation causes the application to crash

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-06-05T15:52:21.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sRelease 2.1.0, Sprint 2012-12 API
ComponentsAndroid
LabelsCommunity, api, module_label, qe-testadded, regression
ReporterPete Berry
AssigneeJosh Roesslein
Created2012-05-25T13:48:22.000+0000
Updated2012-07-13T16:27:27.000+0000

Description

This happens when numerous labels are created, one right after another. The following example fails while creates 35 rows each with 25 columns. Notice that several properties for the label are set after the label is created:
var win1 = Ti.UI.currentWindow;
var BaleReportWindow = Ti.UI.currentWindow;

var HScrollView=Ti.UI.createScrollView({backgroundColor:'black',
                                        showVerticalScrollIndicator:false,
                                        showHorizontalScrollIndicator:true,
                                        scrollType:'horizontal'});
var VScrollView=Ti.UI.createScrollView({backgroundColor:'black',
                                        showVerticalScrollIndicator:true,
                                        showHorizontalScrollIndicator:false,
                                        scrollType:'vertical'});
Ti.UI.currentWindow.add(HScrollView);
HScrollView.add(VScrollView);

var RowCount=35;
var ColCount=25;
var RowHeight=21;
var ColWidth=50;
var TheLabel;
var TheRow;
var TheCol;

for (var Y=1; Y<=RowCount; Y++)
{
  TheRow=Ti.UI.createView({top:((Y-1)*RowHeight), 
                           height:RowHeight+1,
                           backgroundColor:'gray'});
  for (var X=1; X<=ColCount; X++)
  {
    TheLabel=Ti.UI.createLabel({text:Y + '.' + X,
/*  
                                color:'black',
                                left:1+((X-1)*(ColWidth+1)),
                                width:ColWidth,
                                height:RowHeight,
                                top:1,
 */                                
                                backgroundColor:'white'});
/* */                                 
    TheLabel.color='black';
    TheLabel.left=1+((X-1)*(ColWidth+1));
    TheLabel.width=ColWidth;
    TheLabel.height=RowHeight;
    TheLabel.top=1;
/* */                                    
    TheRow.add(TheLabel);
  }
  VScrollView.add(TheRow);
}

In the following example the same properties are set at creation time, the application does not crash:
var win1 = Ti.UI.currentWindow;
var BaleReportWindow = Ti.UI.currentWindow;

var HScrollView=Ti.UI.createScrollView({backgroundColor:'black',
                                        showVerticalScrollIndicator:false,
                                        showHorizontalScrollIndicator:true,
                                        scrollType:'horizontal'});
var VScrollView=Ti.UI.createScrollView({backgroundColor:'black',
                                        showVerticalScrollIndicator:true,
                                        showHorizontalScrollIndicator:false,
                                        scrollType:'vertical'});
Ti.UI.currentWindow.add(HScrollView);
HScrollView.add(VScrollView);

var RowCount=35;
var ColCount=25;
var RowHeight=21;
var ColWidth=50;
var TheLabel;
var TheRow;
var TheCol;

for (var Y=1; Y<=RowCount; Y++)
{
  TheRow=Ti.UI.createView({top:((Y-1)*RowHeight), 
                           height:RowHeight+1,
                           backgroundColor:'gray'});
  for (var X=1; X<=ColCount; X++)
  {
    TheLabel=Ti.UI.createLabel({text:Y + '.' + X,
/* */
                                color:'black',
                                left:1+((X-1)*(ColWidth+1)),
                                width:ColWidth,
                                height:RowHeight,
                                top:1,
/* */                                
                                backgroundColor:'white'});
/*                                 
    TheLabel.color='black';
    TheLabel.left=1+((X-1)*(ColWidth+1));
    TheLabel.width=ColWidth;
    TheLabel.height=RowHeight;
    TheLabel.top=1;
 */                                    
    TheRow.add(TheLabel);
  }
  VScrollView.add(TheRow);
}

It is important to note that this does not occur with small amounts of data. For example change the RowCount to 5 and both code examples above work as expected. This appears to be similar to the bug reported in TIMOB-8289 however it somewhat different. This worked when we release with SDK 1.7.? I will continue to test in hopes to find when this problem appeared.

Comments

  1. Josh Roesslein 2012-06-04

    Sent [PR #2321](http://github.com/appcelerator/titanium_mobile/pull/2321) to resolve this issue. This also appears to fix the test case in TIMOB-8289.
  2. Satyam Sekhri 2012-06-05

    Adding label properties after creation of label work fine and does not crash the application Verified on: Titanium Studio: 2.1.0.201206041625 Titanium SDK: 2.1.0.v20120605190238 Android SDK: Google APIs Android 2.3.3 Android Runtime: v8, Rhino
  3. Pete Berry 2012-07-05

    Please reopen this bug. Running the first bit of example code above still cause the application to fail with SDK version 2.1.0.GA. Thank you, Pete
  4. Josh Roesslein 2012-07-05

    Pete, could you provide us with a log of the crash?
  5. Pete Berry 2012-07-13

    Confirmed fixed in 2.1.0.GA

JSON Source