Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12134] Android: window borderWidth:0 crashes when in tabGroup

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-01-28T23:32:28.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sRelease 3.1.0, 2013 Sprint 02 Core, 2013 Sprint 02
ComponentsAndroid
Labelscommunity, qe-testadded, regression
ReporterFederico Casali
AssigneeSunila
Created2012-12-16T15:10:59.000+0000
Updated2014-03-20T00:07:40.000+0000

Description

Problem description

Setting 'borderWidth' for a window in a tabGroup crashes the App Not reproducible with TiSDK 2.1.4 GA

Steps to reproduce:

Start from the KitchenSink BaseUIWindow.js Add borderWidth: 0 in the self (window) definition as follows:
function BaseUIWindow(title) {
    var self = Ti.UI.createWindow({
        title:title,
        backgroundColor:'white',
        borderWidth : 0    // Add this line
});
The app will crash in the simulator and on the device with the following error:
[1028,1028] Sending event: exception on thread: main msg:java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.; Titanium 3.0.0,2012/12/12 18:49,a5894b3
[ERROR][TiApplication(13705)] java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
[ERROR][TiApplication(13705)] 	at android.view.ViewGroup.addViewInner(ViewGroup.java:3337)
[ERROR][TiApplication(13705)] 	at android.view.ViewGroup.addView(ViewGroup.java:3208)
[ERROR][TiApplication(13705)] 	at android.view.ViewGroup.addView(ViewGroup.java:3188)
[ERROR][TiApplication(13705)] 	at org.appcelerator.titanium.view.TiUIView.initializeBorder(TiUIView.java:953)
[ERROR][TiApplication(13705)] 	at org.appcelerator.titanium.view.TiUIView.processProperties(TiUIView.java:697)
[ERROR][TiApplication(13705)] 	at ti.modules.titanium.ui.widget.TiView.processProperties(TiView.java:49)
[ERROR][TiApplication(13705)] 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:893)
[ERROR][TiApplication(13705)] 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:310)
[ERROR][TiApplication(13705)] 	at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:107)
[ERROR][TiApplication(13705)] 	at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR][TiApplication(13705)] 	at android.os.Looper.loop(Looper.java:137)
[ERROR][TiApplication(13705)] 	at android.app.ActivityThread.main(ActivityThread.java:4514)
[ERROR][TiApplication(13705)] 	at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR][TiApplication(13705)] 	at java.lang.reflect.Method.invoke(Method.java:511)
[ERROR][TiApplication(13705)] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
[ERROR][TiApplication(13705)] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
[ERROR][TiApplication(13705)] 	at dalvik.system.NativeStart.main(Native Method)

Comments

  1. Sunila 2013-01-22

    Pull request https://github.com/appcelerator/titanium_mobile/pull/3752 If the view already has a parent, it needs to be removed before adding to the borderView. borderView is then added to the original parent. Tested the kitchensink sample, works without crash.
  2. Allen Yeung 2013-01-28

    test case:
       // this sets the background color of the master UIView (when there are no windows/tab groups on it)
       Titanium.UI.setBackgroundColor('#000');
       
       // create tab group
       var tabGroup = Titanium.UI.createTabGroup();
       
       //
       // create base UI tab and root window
       //
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff',
           borderWidth : 1,
           borderColor: 'red'
           
       });
       var tab1 = Titanium.UI.createTab({  
           icon:'KS_nav_views.png',
           title:'Tab 1',
           window:win1
       });
       
       var label1 = Titanium.UI.createLabel({
       	color:'#999',
       	text:'I am Window 1',
       	font:{fontSize:20,fontFamily:'Helvetica Neue'},
       	textAlign:'center',
       	width:'auto'
       });
       
       win1.add(label1);
       
       //
       // create controls tab and root window
       //
       var win2 = Titanium.UI.createWindow({  
           title:'Tab 2',
           backgroundColor:'#fff'
       });
       var tab2 = Titanium.UI.createTab({  
           icon:'KS_nav_ui.png',
           title:'Tab 2',
           window:win2
       });
       
       var label2 = Titanium.UI.createLabel({
       	color:'#999',
       	text:'I am Window 2',
       	font:{fontSize:20,fontFamily:'Helvetica Neue'},
       	textAlign:'center',
       	width:'auto'
       });
       
       win2.add(label2);
       
       //
       //  add tabs
       //
       tabGroup.addTab(tab1);  
       tabGroup.addTab(tab2);  
       
       // open tab group
       tabGroup.open();
       
       
    1. Run test case Expected result: Tabgroup opens without crashing Actual result: App crashes when opening tab group
  3. Vishal Duggal 2013-01-28

    backport PR https://github.com/appcelerator/titanium_mobile/pull/3809
  4. Paras Mishra 2013-02-22

    App runs successfully and no crashes. Verified on: Google Nexus, android : 4.1 SDK version: 3.1.0.v20130220200300 CLI version : 3.0.24 OS : MAC OSX 10.7.5 XCode : 4.5.1

JSON Source