Problem
In version 3.1.3 and above tapping the tab's button to return to the root window of the tab orphans any windows between the current window and the root window. This works as expected in 3.1.2 GA but 3.1.3 has serious regression bug
Why This Is A Problem
Orphaned windows equate to leaked memory. Windows in the middle of the root and last window are orphaned and all resources are trapped. Causes crash on device after lots of use.
Expected Behavior
Tapping the tab's button should close every window that is open on that tab's stack, not just the current window. On version 3.1.2 it does the following which is correct:
[ERROR] : Opened: A
[ERROR] : Opened: B
[ERROR] : Opened: C
[ERROR] : Closed: C
[ERROR] : Closed: B
[ERROR] : Closed: A
Reproduction
Drop the following in an app.js. Use the Open Window A, B & C buttons to drill through the widows. Notice in the log which windows were opened, and which were closed. Tap the tab to return to root and only the last window (window c) is closed.
Test Case
// Create Tab Group
var tabGrp = Ti.UI.createTabGroup({
backgroundColor:'white',
});
// Tab Window 1
var win1 = Ti.UI.createWindow({
backgroundColor:'red',
title:'Tab 1'
});
var button1 = Ti.UI.createButton({ title: 'Open Window A' });
button1.addEventListener('click', function(event) {
tab1.open(winA);
});
win1.add(button1);
// Tab Window 2
var win2 = Ti.UI.createWindow({
backgroundColor:'green',
title:'Tab 2'
});
// Tab Window 3
var win3 = Ti.UI.createWindow({
backgroundColor:'blue',
title:'Tab 3'
});
// Child Window A
var winA = Ti.UI.createWindow({
backgroundColor:'yellow',
title:'Window A'
});
var buttonA = Ti.UI.createButton({ title: 'Open Window B' });
buttonA.addEventListener('click', function(event) {
tab1.open(winB);
});
winA.add(buttonA);
winA.addEventListener('open', function(event) {
Ti.API.error('Opened: A');
});
winA.addEventListener('close', function(event) {
Ti.API.error('Closed: A');
});
// Child Window B
var winB = Ti.UI.createWindow({
backgroundColor:'yellow',
title:'Window B'
});
var buttonB = Ti.UI.createButton({ title: 'Open Window C' });
buttonB.addEventListener('click', function(event) {
tab1.open(winC);
});
winB.add(buttonB);
winB.addEventListener('open', function(event) {
Ti.API.error('Opened: B');
});
winB.addEventListener('close', function(event) {
Ti.API.error('Closed: B');
});
// Child Window C
var winC = Ti.UI.createWindow({
backgroundColor:'yellow',
title:'Window C'
});
winC.addEventListener('open', function(event) {
Ti.API.error('Opened: C');
});
winC.addEventListener('close', function(event) {
Ti.API.error('Closed: C');
});
// Add Tabs
var tab1 = Ti.UI.createTab({window:win1,title:'TAB1'});
var tab2 = Ti.UI.createTab({window:win2,title:'TAB2'});
var tab3 = Ti.UI.createTab({window:win3,title:'TAB3'});
tabGrp.addTab(tab1);
tabGrp.addTab(tab2);
tabGrp.addTab(tab3);
// Open Tab Group
tabGrp.open();
Logs
[ERROR] : Opened: A
[ERROR] : Opened: B
[ERROR] : Opened: C
[ERROR] : Closed: C
Valid Bug. Memory Leak.
Pull pending master - https://github.com/appcelerator/titanium_mobile/pull/4690 3_1_X - https://github.com/appcelerator/titanium_mobile/pull/4691
Thanks for resolving so quickly!
Verified the Fix with: Appcelerator Studio: 3.1.3.201309132456 SDK: 3.1.3.v20130916153052 acs:1.0.6 alloy:1.2.2-cr npm:1.3.2 titanium:3.1.2 titanium-code-processo:1.0.2 OSX: 10.8.4 Xcode:5.0 GM seed Devices: Simulator(v7.0),ipod Touch2(v7.0) Tapping the tab's button now closes every window that is open on that tab's stack, not just the current window.Working Fine.