Problem Description
App is crashing when you close the tabgroup.
Expected results
The tabgroup closing.
Actual results
The app showing an error "the app has stopped unexpectedly". We got more info in DDMS, please check the "Extra info" field at the bottom of this report.
Test Case
1. Create new mobile project.
2. Add this app.js:
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
});
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',
textAlign:'center',
width:'auto'
});
win1.add(label1);
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',
textAlign:'center',
width:'auto'
});
win2.add(label2);
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.open();
tabGroup.close();
Extra info
This same code is working fine in iOS and Mobile Web.
The DDMS output related to the crash, here:
06-28 15:50:30.827: E/TiApplication(4914): (main) [51,624] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.negoapps.ingtesttabgroup/com.negoapps.ingtesttabgroup.IngtesttabgroupActivity}: java.lang.NullPointerException; Titanium 2.1.0,2012/06/28 11:42,c6b7897
06-28 15:50:30.827: E/TiApplication(4914): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.negoapps.ingtesttabgroup/com.negoapps.ingtesttabgroup.IngtesttabgroupActivity}: java.lang.NullPointerException
06-28 15:50:30.827: E/TiApplication(4914): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-28 15:50:30.827: E/TiApplication(4914): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-28 15:50:30.827: E/TiApplication(4914): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-28 15:50:30.827: E/TiApplication(4914): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-28 15:50:30.827: E/TiApplication(4914): at android.os.Handler.dispatchMessage(Handler.java:99)
06-28 15:50:30.827: E/TiApplication(4914): at android.os.Looper.loop(Looper.java:130)
06-28 15:50:30.827: E/TiApplication(4914): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-28 15:50:30.827: E/TiApplication(4914): at java.lang.reflect.Method.invokeNative(Native Method)
06-28 15:50:30.827: E/TiApplication(4914): at java.lang.reflect.Method.invoke(Method.java:507)
06-28 15:50:30.827: E/TiApplication(4914): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:850)
06-28 15:50:30.827: E/TiApplication(4914): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
06-28 15:50:30.827: E/TiApplication(4914): at dalvik.system.NativeStart.main(Native Method)
06-28 15:50:30.827: E/TiApplication(4914): Caused by: java.lang.NullPointerException
06-28 15:50:30.827: E/TiApplication(4914): at ti.modules.titanium.ui.TabGroupProxy.handleClose(TabGroupProxy.java:322)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:106)
06-28 15:50:30.827: E/TiApplication(4914): at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:98)
06-28 15:50:30.827: E/TiApplication(4914): at android.os.Handler.dispatchMessage(Handler.java:95)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.kroll.common.TiMessenger.dispatchMessage(TiMessenger.java:365)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.kroll.common.TiMessenger.dispatchPendingMessages(TiMessenger.java:350)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.kroll.common.TiMessenger$2.getResult(TiMessenger.java:235)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:262)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.kroll.common.TiMessenger.sendBlockingRuntimeMessage(TiMessenger.java:187)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:605)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:428)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:162)
06-28 15:50:30.827: E/TiApplication(4914): at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:99)
06-28 15:50:30.827: E/TiApplication(4914): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-28 15:50:30.827: E/TiApplication(4914): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-28 15:50:30.827: E/TiApplication(4914): ... 11 more
06-28 15:50:30.928: E/AndroidRuntime(4914): FATAL EXCEPTION: main
06-28 15:50:30.928: E/AndroidRuntime(4914): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.negoapps.ingtesttabgroup/com.negoapps.ingtesttabgroup.IngtesttabgroupActivity}: java.lang.NullPointerException
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.os.Handler.dispatchMessage(Handler.java:99)
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.os.Looper.loop(Looper.java:130)
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-28 15:50:30.928: E/AndroidRuntime(4914): at java.lang.reflect.Method.invokeNative(Native Method)
06-28 15:50:30.928: E/AndroidRuntime(4914): at java.lang.reflect.Method.invoke(Method.java:507)
06-28 15:50:30.928: E/AndroidRuntime(4914): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:850)
06-28 15:50:30.928: E/AndroidRuntime(4914): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
06-28 15:50:30.928: E/AndroidRuntime(4914): at dalvik.system.NativeStart.main(Native Method)
06-28 15:50:30.928: E/AndroidRuntime(4914): Caused by: java.lang.NullPointerException
06-28 15:50:30.928: E/AndroidRuntime(4914): at ti.modules.titanium.ui.TabGroupProxy.handleClose(TabGroupProxy.java:322)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:106)
06-28 15:50:30.928: E/AndroidRuntime(4914): at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:98)
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.os.Handler.dispatchMessage(Handler.java:95)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.kroll.common.TiMessenger.dispatchMessage(TiMessenger.java:365)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.kroll.common.TiMessenger.dispatchPendingMessages(TiMessenger.java:350)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.kroll.common.TiMessenger$2.getResult(TiMessenger.java:235)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:262)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.kroll.common.TiMessenger.sendBlockingRuntimeMessage(TiMessenger.java:187)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:605)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:428)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:162)
06-28 15:50:30.928: E/AndroidRuntime(4914): at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:99)
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-28 15:50:30.928: E/AndroidRuntime(4914): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-28 15:50:30.928: E/AndroidRuntime(4914): ... 11 more
This is caused by closing the tab group before it has fully opened.
Closing a TabGroup before the "open" event has fired is not supported. There can be some lag between calling open() and the new tab group being fully opened on Android especially on slower devices (ex: emulator). By placing the close call inside an "open" event listener on the tab group the crash goes away.
Closing as invalid, see comment above why this isn't correct.
Closing ticket as invalid with reference to the above comments.