Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10338] Android: Opening a new tab group after closing a tab group crashes the application

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-08-21T16:45:37.000+0000
Affected Version/sRelease 2.1.0, Release 2.1.1
Fix Version/sSprint 2012-17 API, Release 3.0.0
ComponentsAndroid
Labelsapi, module_tabgroup, qe-review, qe-testadded
ReporterBetty Tran
AssigneeHieu Pham
Created2012-08-08T07:13:40.000+0000
Updated2012-09-10T03:55:24.000+0000

Description

Problem

When closing a tab group followed by creating and opening a new tab group, the application crashes.

Steps to reproduce

1. The app starts and the first tab group is opened 2. Click on the button to close the first tab group and create and open another tab group 3. Application crashes

Code to reproduce

var rootWin = Ti.UI.createWindow({
	backgroundColor : 'pink',
	exitOnClose : true,
	navBarHidden : true
});

rootWin.open();

var tabGroup = Ti.UI.createTabGroup();

var win1 = Ti.UI.createWindow({
	backgroundColor : 'orange'
});


var aButton = Ti.UI.createButton({
	title : 'Button',
	height : Ti.UI.SIZE,
	width : Ti.UI.SIZE
});


aButton.addEventListener('click', function() {

	tabGroup.close();
	tabGroup = null;

	var tabGroup2 = Ti.UI.createTabGroup();

	var win21 = Ti.UI.createWindow({
		backgroundColor : 'orange'
	});

	var tab21 = Ti.UI.createTab({
		window : win21
	});

	tabGroup2.addTab(tab21);

	tabGroup2.open();
});

win1.add(aButton);

var win2 = Ti.UI.createWindow({
	backgroundColor : 'lime'
});

var tab1 = Ti.UI.createTab({
	window : win1
});
var tab2 = Ti.UI.createTab({
	window : win2
});

tabGroup.addTab(tab1);
tabGroup.addTab(tab2);

tabGroup.open();

Expected behavior

First tab group is closed and new tab group is opened.

Actual behavior

Application crashes Please find attached the crash log.

Attachments

FileDateSize
log.txt2012-08-08T07:14:43.000+000017890

Comments

  1. Opie Cyrus 2012-08-16

    Window open is an asynchronous operation and it is not safe to assume that the Tab Group will not be opened as the root activity for the task. Both the window and tab group are basically in a race to be the root activity. If a true chaining is desired (first window then tab group), it is possible to open the tab group once the window has been opened via open event listener. The default behavior of the application should be to exit when the root activity is closed.
  2. Anshu Mittal 2012-09-10

    Verified on: SDK: 2.2.0.v20120907162025 STUDIO: 2.1.3.201209071738 Devices: Samsung galaxy note(v 2.3.6), iOS simulator According to Opie Cyrus comment,tab group is opened after window is opened via open event listener. Following code is being used to test the scenario: var rootWin = Ti.UI.createWindow({ backgroundColor : 'pink', exitOnClose : true, navBarHidden : true }); rootWin.addEventListener('open', function(e) { var tabGroup = Ti.UI.createTabGroup(); var win1 = Ti.UI.createWindow({ backgroundColor : 'orange' }); var aButton = Ti.UI.createButton({ title : 'Button', height : Ti.UI.SIZE, width : Ti.UI.SIZE }); aButton.addEventListener('click', function() { tabGroup.close(); tabGroup = null; var tabGroup2 = Ti.UI.createTabGroup(); var win21 = Ti.UI.createWindow({ backgroundColor : 'orange' }); var tab21 = Ti.UI.createTab({ window : win21 }); tabGroup2.addTab(tab21); tabGroup2.open(); }); win1.add(aButton); var win2 = Ti.UI.createWindow({ backgroundColor : 'lime' }); var tab1 = Ti.UI.createTab({ window : win1 }); var tab2 = Ti.UI.createTab({ window : win2 }); tabGroup.addTab(tab1); tabGroup.addTab(tab2); tabGroup.open(); }); rootWin.open();

JSON Source