Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13636] iOS: Modals created with formsheet style leak a TiUIiPhoneProxy object

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2017-06-11T17:41:37.000+0000
Affected Version/sRelease 3.1.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterWilliam G
AssigneeEric Merriman
Created2013-04-10T00:41:36.000+0000
Updated2017-06-12T22:33:32.000+0000

Description

Problem

When a modal window is created *and* a modalStyle is defined, a TiUIiPhoneProxy object is left behind as measured via Allocations in Instruments. Not specifying a modal style resolves this. It only manifests if modal & modalstyle & subsequent open.

Test case

/*
 * Bug Sample -
 * 
 * To reproduce:
 * 1) Launch this app in the iPad simulator on current iOS SDK
 * 2) Start Instruments, setup allocation to monitor the app after it starts so that your view isn't cluttered with the base window elements which are unimportant
 * 3) Filter Instruments to TiUI
 * 3a) Do not use 'Simulate Memory Warning' in the simulator unless instructed.
 * 4) Click the 'open modal window' button, close the modal window, repeat opening/closing 10 times. Note that objects all clear when automatically GC'd, and the number doesn't increment on anything past the last click waiting on GC
 * 5) Now, click 'simulate memory warning' in the simulator. Click 'open modal window' and then close it. Note that a new TiUiIphoneProxy has appeared in Instruments. This only occurs after the first modal has appeared and a memory warning has triggered, but it will show for all subsequent events
 * 6) Repeat clicking 'simulate memory warning', then clicking 'open modal window', then closing the window. Note that on 3.1.0.v20130405170202, the living count continues rising.
 * 7) Modify the code to remove the modal style, and everything will then properly zero out even with memory warnings
 */

//simplified to just show a single window
(function() {
	
	
	//create component instance
	var self = Ti.UI.createWindow({
		backgroundColor:'#ffffff'
	});
		
	//construct UI
	var modalLaunchButton = Ti.UI.createButton({title : 'open modal window (breaks)', left: 20, right: 20, top:10, height:40});
	modalLaunchButton.addEventListener('click',function(){
	
		//create component instance
		var Window = Ti.UI.createWindow({
			backgroundColor:'#ffffff'
		});
			
		//construct UI
		Window.add(Ti.UI.createLabel({text: 'i am the modal window.If you close me, simulate a memory warning, and reopen me, i wont give up my TiUIiPhoneProxy object'}));
		
		var closeNavBtn = Ti.UI.createButton({title : 'close'});
		closeNavBtn.addEventListener('click',function(){
			Window.leftNavButton = null;
			closeNavBtn = null;
			Window.close();
			Window = null;
		});
		Window.leftNavButton = closeNavBtn;
		
		
		Window.open({
			modal: true,
			modalStyle: Ti.UI.iPhone.MODAL_PRESENTATION_FORMSHEET
		});
	});
	self.add(modalLaunchButton);
		
	//construct UI
	var modalLaunchButtonWithoutStyle = Ti.UI.createButton({title : 'open modal window without style (passes)', left: 20, right: 20, top:100, height:40});
	modalLaunchButtonWithoutStyle.addEventListener('click',function(){
	
		//create component instance
		var Window = Ti.UI.createWindow({
			backgroundColor:'#ffffff'
		});
			
		//construct UI
		Window.add(Ti.UI.createLabel({text: 'i am the modal window without style, I do not eat memory because I dont have a modalStyle defined, so even a memory warning doesnt cause me to hold onto TiUIiPhoneProxy'}));
		
		var closeNavBtn = Ti.UI.createButton({title : 'close'});
		closeNavBtn.addEventListener('click',function(){
			Window.leftNavButton = null;
			closeNavBtn = null;
			Window.close();
			Window = null;
		});
		Window.leftNavButton = closeNavBtn;
		
		
		Window.open({
			modal: true
		});
	});
	self.add(modalLaunchButtonWithoutStyle);
	self.open();
	
})();

Logs

I don't know how to provide a useful log of this (Instruments maybe?)

Steps to reproduce

See comment in example code. Run Instruments with the Allocations report, open and close the modal a few times, note that everything cleans up. Now, trigger a memory warning, open and close the modal,note that the TiUIiPhoneProxy doesnt go away. For every memory warning+open/close cycle you run, another object stays living. Use the second button and note that even with memory warnings, things clean up properly.

Discussions

A Q&A has not been created for this item, as it's just an incorrect behavior report.

Comments

  1. Daniel Sefton 2013-04-19

    Tested on iOS 6 iPad simulator and device with Ti SDK 3.1 GA. The TiUIiPhoneProxy object is *always* left behind after showing the modal window with style, regardless of triggering a memory warning simulation. Performing subsequent memory warning simulations doesn't accumulate any further objects. The modal window without style never creates the TiUIiPhoneProxy object.
  2. Hans Knöchel 2017-06-11

    Cannot reproduce with Ti.UI.iOS.NavigationWindow these days.
  3. Lee Morris 2017-06-12

    Closing ticket with reference to the above comment.

JSON Source