Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10891] iOS: App having 'tabgroup containing map' crashes when opened from a window (iOS 6)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-10-17T20:17:19.000+0000
Affected Version/sRelease 2.1.3
Fix Version/sRelease 3.0.0, Release 3.1.0, 2012 Sprint 21 API, 2012 Sprint 21
ComponentsiOS
Labelsapi, module_tabgroup, qe-ios090112, qe-ios6, qe-testadded
ReporterShyam Bhadauria
AssigneeVishal Duggal
Created2012-09-13T04:49:01.000+0000
Updated2013-01-08T14:46:27.000+0000

Description

This is not a regression. It happens on 2.1.2 also. App do not crashes on iOS 5.1 Steps to reproduce: 1. Use the app below
var basewin = Ti.UI.createWindow();
basewin.open();

var openwin1 = Ti.UI.createButton({
        title:"Case 1",
    });

basewin.add(openwin1);

openwin1.addEventListener('click', function(e) {
		var tabGroup = Titanium.UI.createTabGroup();
		var _window = Ti.UI.createWindow();
	    _window.title='Tab 1';
	    _window.backgroundColor='#fff';
	
	 
		var tab1 = Titanium.UI.createTab({ 
		    icon:'KS_nav_views.png',
		    title:'Tab 1',
		    window:_window
		});
		var regionSV = {latitude:37.337681,longitude:-122.038193,latitudeDelta:0.04, longitudeDelta:0.04};
		 
		  var mapview = Titanium.Map.createView({
		    mapType: Titanium.Map.STANDARD_TYPE,
		    animate:true,
		    region: regionSV,
		    regionFit:true,
		    userLocation:true,
		    visible: true,
		});
		_window.add(mapview);
		 
		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);
		 
		tabGroup.addTab(tab1); 
		tabGroup.addTab(tab2); 
		tabGroup.open();
		
		var close = Ti.UI.createButton({
		        title:"Close",
		        bottom:'20dp',
		        height:'35dp',
		        width:'180dp'
		});
		
		close.addEventListener('click', function(e) {
		        tabGroup.close();
		 		basewin.open();
		});
		tabGroup.add(close); 
		
});
2. Run app on iOS 6.Click the 'Case 1' button. 3. Click the 'Close' button. 4. Click the 'Case 1' button again(may need to repeat steps 2 to 4 couple of times). Expected result 2. After step 2, a tabgroup with a map in first tab will get open. 3. Tabgroup will be closed.Initial window will be displayed. 4. Again the tabgroup with a map in first tab should get open. Actual result: 2. After step 2, a tabgroup with a map in first tab will get open. 3. Tabgroup will be closed.Initial window is displayed. 4. The tabgroup opens up, but after a while the app also crahes. Device logs are attached with the bug.

Attachments

FileDateSize
Map1309120457PM.crash2012-09-13T04:49:01.000+000053669

Comments

  1. Sabil Rahim 2012-09-14

    On iOS 6 apple changed the mapview engine.Which is not smart enough to stop rendering once the view itself is off screen. Solution is to remove tab after the closing the tabGroup in the close eventListener function. Remove tab will ensure the mapview is removed properly.This doesnot occur with windows because windows detach views on closing.But tabGroups donot detach tabs on closing, since they can be opened again and the expected behavior is to restore the existing tabs again. Modified code snippet.
               close.addEventListener('click', function(e) {
                       tabGroup.close();
       				tabGroup.removeTab(tab1);
       				tabGroup.removeTab(tab2);
               });
       
       
  2. Sabil Rahim 2012-09-14

    Marking ticket as invalid.
  3. Ingo Muschenetz 2012-09-14

    Recommend documenting it for the release on the 18th, and attempting a better fix for the 28th.
  4. Vishal Duggal 2012-10-13

    State Retention Test 1. Set memoryTest variable to false 2. Open tabGroup. 3. Open a bunch of windows on either tab. 4. Close Tab Group. 5. Open Tab Group Again Expected result - TabGroup is exactly where we left off. Memory Test 1 1. Set memoryTest variable to true 2. Open Tab Group 3. Close Tab Group 4. Simulate memory warning. Expected result - 1 Button and 1 Window proxy Memory Test 2 1. Set memoryTest variable to true 2. Open Tab Group 3. Switch to Tab2 4. Close Tab Group 5. Simulate memory warning Expected result - 1 Button and 1 Window proxy Memory Test 3 1. Set memoryTest variable to true 2. Open Tab Group 3. Open a bunch of windows on Tab1 4. Close Tab Group 5. Simulate memory warning Expected result - 1 Button and 1 Window proxy Memory Test 4 1. Set memoryTest variable to true 2. Open Tab Group 3. Open a bunch of windows on Tab1 4. Switch to Tab2 5. Close Tab Group 6. Simulate memory warning Expected result - 1 Button and 1 Window proxy Memory Test 5 1. Set memoryTest variable to true 2. Open Tab Group 3. Open a bunch of windows on Tab1 4. Switch to Tab2 5. Open a bunch of windows on Tab2 6. Close Tab Group 7. Simulate memory warning Expected result - 1 Button and 1 Window proxy Test Code below
       var base = Ti.UI.createWindow({
       	backgroundColor:'black'
       });
       
       var b = Ti.UI.createButton({
       	title:'OPEN TABGROUP'
       })
       
       base.add(b);
       
       var memoryTest = false;
       
       var tabGroup = null;
       var counter1 = 1;
       var initWindow = function(Thetitle, theTab)
       {
       	var win = Ti.UI.createWindow({
       		backgroundColor:'white',
       		title:Thetitle
       	});
       	
       	var b1 = Ti.UI.createButton({
       		title:'CLOSE TAB GROUP',
       		top:10
       	})
       	
       	b1.addEventListener('click',function(){
       		tabGroup.close();
       	});
       	
       	var b2 = Ti.UI.createButton({
       		title:'ADD ANOTHER',
       		bottom:10
       	});
       	
       	b2.addEventListener('click',function(){
       		var temp2 = 'ANOTHER '+counter1;
       		var win1 = initWindow(temp2, theTab);
       		theTab.open(win1);
       		
       	});
       	
       	win.addEventListener('open',function(e){
       		counter1 ++;
       		Ti.API.info('WINDOW OPENED '+counter1);
       	});
       	win.addEventListener('close',function(e){
       		counter1 --;
       		Ti.API.info('WINDOW CLOSED '+counter1);
       	});
       	
       	win.add(b1);
       	win.add(b2);
       
       	return win;
       }
       
       var initTabGroup = function()
       {
       	tabGroup = Ti.UI.createTabGroup();
       	
       	var tab1 = Ti.UI.createTab({
       		title:'THE TAB'
       	});
       	var win1 = initWindow('TAB1', tab1);
       	tab1.window = win1;
       
       	var tab2 = Ti.UI.createTab({
       		title:'the TAB'
       	});
       	var win2 = initWindow('TAB2', tab2);
       	tab2.window = win2;
       	
       	tabGroup.addTab(tab1);
       	tabGroup.addTab(tab2);
       }
       
       b.addEventListener('click',function(){
       
       	if (!tabGroup) {
       		initTabGroup();
       	}
       	tabGroup.open();
       	
       	if (memoryTest == true) {
       		tabGroup.addEventListener('close',function(){
       			Ti.API.info('TAB GROUP CLOSED');
       			tabGroup = null;
       		});
       	}
       	
       });
       
       base.open();
       
  5. Vishal Duggal 2012-10-13

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/3203
  6. Vishal Duggal 2012-10-17

    3_0_X PR https://github.com/appcelerator/titanium_mobile/pull/3267
  7. Max Stepanov 2012-10-18

    3_0_X crash:
       Thread 4 name:  KrollContext<kroll$1>
       Thread 4 Crashed:
       0   libobjc.A.dylib               	0x31686fd8 objc_msgSend + 44
       1   CoreFoundation                	0x37aef020 CFRetain + 76
       2   CoreFoundation                	0x37af8bac +[__NSArrayI __new::] + 48
       3   CoreFoundation                	0x37af8ac6 -[__NSPlaceholderArray initWithObjects:count:] + 294
       4   UIKit                         	0x34f87aa0 -[UIView dealloc] + 76
       5   libobjc.A.dylib               	0x316880be _objc_rootRelease + 30
       6   UIKit                         	0x34f5fb48 -[UIView(Hierarchy) removeFromSuperview] + 176
       7   UIKit                         	0x34f87b5e -[UIView dealloc] + 266
       8   UIKit                         	0x35029b7e -[UINavigationTransitionView dealloc] + 162
       9   libobjc.A.dylib               	0x316880be _objc_rootRelease + 30
       10  UIKit                         	0x34f5fb48 -[UIView(Hierarchy) removeFromSuperview] + 176
       11  UIKit                         	0x34f87b5e -[UIView dealloc] + 266
       12  UIKit                         	0x35029a88 -[UILayoutContainerView dealloc] + 84
       13  libobjc.A.dylib               	0x316880be _objc_rootRelease + 30
       14  UIKit                         	0x3502918e -[UIViewController dealloc] + 222
       15  UIKit                         	0x35029010 -[UINavigationController dealloc] + 192
       16  libobjc.A.dylib               	0x316880be _objc_rootRelease + 30
       17  Titanium                      	0x0008afd4 0x1000 + 565204
       18  Titanium                      	0x0008b0f2 0x1000 + 565490
       19  Titanium                      	0x000a69ca 0x1000 + 678346
       20  libobjc.A.dylib               	0x316880be _objc_rootRelease + 30
       21  Titanium                      	0x0004c054 0x1000 + 307284
       22  libobjc.A.dylib               	0x316880be _objc_rootRelease + 30
       23  Titanium                      	0x0004aaea 0x1000 + 301802
       24  Titanium                      	0x00209e62 0x1000 + 2133602
       25  Titanium                      	0x00229cc2 0x1000 + 2264258
       26  Titanium                      	0x0022a3da 0x1000 + 2266074
       27  Titanium                      	0x0022a36e 0x1000 + 2265966
       28  Titanium                      	0x00209920 0x1000 + 2132256
       29  Titanium                      	0x00044792 0x1000 + 276370
       30  Titanium                      	0x00045a0a 0x1000 + 281098
       31  Foundation                    	0x31a4ca8a -[NSThread main] + 66
       32  Foundation                    	0x31ae059a __NSThread__main__ + 1042
       33  libsystem_c.dylib             	0x35fcec16 _pthread_start + 314
       34  libsystem_c.dylib             	0x35fcead0 thread_start + 0
       
       
  8. Olga Romero 2012-12-04

    closing as fixed. Tested and verified fix with: Titanium Studio, build: 3.0.0.201211301903 Titanium SDK, build: 3.0.0.v20121130200208 Device: iPad mini iOS 6.0.1

JSON Source