Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18186] iOS: App is crashing when adding the same tab many times

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2016-10-18T12:49:22.000+0000
Affected Version/sRelease 3.5.0
Fix Version/sn/a
ComponentsiOS
Labelsqe-3.5.0
ReporterKajenthiran Velummaylum
AssigneeHans Knöchel
Created2014-12-11T05:57:15.000+0000
Updated2017-03-24T17:59:17.000+0000

Description

This is not a regression since same scenario occurs in 3.4.1 GA

Titanium app is crashing when we add same tab more than once in a TabGroup. Console logs and Crash logs are attached here.

Steps To Reproduce

1. Create a classic app using following code
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();

var win = Titanium.UI.createWindow({
	title : 'Tab',
	backgroundColor : '#fff'
});
var tab = Titanium.UI.createTab({
	icon : 'KS_nav_ui.png',
	title : 'Tab',
	window : win
});
   
var button = Titanium.UI.createButton({
	top : 10,
	title : 'Add tab1'
});
button.addEventListener('click', function(e) {
	tabGroup.addTab(tab1);
});
win.add(button);

// create tab1 and win1
var win1 = Titanium.UI.createWindow({
	title : 'Tab 1',
	backgroundColor : '#fff'
});
var tab1 = Titanium.UI.createTab({
	icon : 'KS_nav_ui.png',
	title : 'Tab 1',
	window : win1
});

tabGroup.addTab(tab);
tabGroup.open();
2. Run on iOS device 3. Click the *Add tab1* button ( It will add a new tab with name *Tab 1* ) 4. Click the button many times until you get *More...* tab 5. Click on the *More...* tab

Actual Result

App is crashing when *More* tab is clicked.

Expected Result

App should not crash. We should handle this gracefully. Note: It can either prevent adding same tab again or allowing them with renaming the properties.

Attachments

FileDateSize
Console.log2014-12-11T05:57:15.000+00004120
CrashLog 12-11-14, 1-41 PM.crash2014-12-11T05:57:15.000+000044142

Comments

  1. Ingo Muschenetz 2014-12-11

    My preference is that the application spit out an error and only add the tab once.
  2. Hans Knöchel 2016-10-18

    This issue is invalid. The demo-code used a circular memory reference that caused the tabs to be referenced outside a scope. The correct use-case would generate and add the tabs as soon the the button is clicked. I made an iterative example that uses a counter to create n tabs. The "More" tab can be clicked without crashes and everything works as expected:
       Titanium.UI.setBackgroundColor('#000');
       var tabGroup = Titanium.UI.createTabGroup();
       var index = 1;
       
       var win = Titanium.UI.createWindow({
           title: 'Tab ' + index,
           backgroundColor: '#fff'
       });
       var tab = Titanium.UI.createTab({
           icon: 'KS_nav_ui.png',
           title: 'Tab ' + index,
           window: win
       });
       
       var button = Titanium.UI.createButton({
           top: 10,
           width: Ti.UI.FILL,
           title: 'Add tab ' + (index + 1)
       });
       
       button.addEventListener('click', function(e) {
           index++;
           button.setTitle('Add tab ' + (index + 1));
       
           // create tab1 and win1
           var win1 = Titanium.UI.createWindow({
               title: 'Tab ' + index,
               backgroundColor: '#fff'
           });
           var tab1 = Titanium.UI.createTab({
               icon: 'KS_nav_ui.png',
               title: 'Tab ' + index,
               window: win1
           });
       
           tabGroup.addTab(tab1);
       });
       
       win.add(button);
       
       tabGroup.addTab(tab);
       tabGroup.open();
       
  3. Lee Morris 2017-03-24

    Closing ticket as invalid with reference to the above comments.

JSON Source