Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14159] iOS: Crash when closing modal window after inputting text into a TextField inside a ScrollView (iPad only)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-06-17T22:35:04.000+0000
Affected Version/sRelease 3.1.0, Release 3.2.0
Fix Version/s2013 Sprint 12 API, 2013 Sprint 12, Release 3.2.0
ComponentsiOS
Labelstriage
ReporterDaniel Sefton
AssigneeSabil Rahim
Created2013-06-07T22:46:58.000+0000
Updated2014-06-19T12:44:33.000+0000

Description

*Problem description* There is a crash when closing a modal window after inputting text into a TextField inside a ScrollView on iPad only. There is no crash on iPhone. *Steps to reproduce* 1. Run the test case on iPad simulator 2. Click Login 3. Input any amount of characters into the TextField 4. Click close on the modal view 5. Wait and observe resulting crash *Workaround* Change the ScrollView to a regular view (see comments). *Test case*
var _resetPasswordControls = {};
var _password = null;

function resetPasswordShow() {
	if (_resetPasswordControls.baseControl == null || _resetPasswordControls.baseControl == undefined) {
		createResetPasswordWindow();
	}

	var options = {
		modal : true,
		modalStyle : Ti.UI.iPhone.MODAL_PRESENTATION_FORMSHEET
	};
	_resetPasswordControls.baseControl.open(options);
};

function resetPasswordClose() {
	_resetPasswordControls.baseControl.passwordSection = null;
	_resetPasswordControls.baseControl.resetPasswordStatusSection = null;
	_password = null;

	if (_resetPasswordControls.baseControl != null) {
		_resetPasswordControls.baseControl.close();
		_resetPasswordControls.baseControl = null;
	}
};

function createResetPasswordWindow() {
	var cancelButton = Ti.UI.createButton({
		systemButton : Ti.UI.iPhone.SystemButton.CANCEL
	});
	_resetPasswordControls.baseControl = Ti.UI.createWindow({
		title : "Reset Password",
		backgroundColor : "#FFF",
		navBarHidden : false,
		modal : true,
		leftNavButton : cancelButton,
		layout : "vertical",
		orientationModes : [Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT, Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT]
	});

	// Allow the window to be closed and destroy all memory associated with it.
	cancelButton.addEventListener('click', resetPasswordClose);

	// CRASH: The scroll view is causing the crash.
	// Change to a regular view to fix crash.
	// Only occurs on iPad.
	_resetPasswordControls.baseControl.passwordSection = Ti.UI.createScrollView({
		backgroundColor : "#FFF",
		top : 10,
		height : 240
	});

	_resetPasswordControls.baseControl.passwordLabel = Ti.UI.createLabel({
		text : "New Password",
		top : 6,
		left : "5%",
		height : 25,
		textAlign : "left",
		font : {
			fontFamily : 'Helvetica Neue',
			fontWeight : 'normal',
			fontSize : 17
		}
	});

	_password = Ti.UI.createTextField({
		top : _resetPasswordControls.baseControl.passwordLabel.top + _resetPasswordControls.baseControl.passwordLabel.height + 2,
		left : "5%",
		width : "90%",
		height : 40,
		passwordMask : true,
		keyboardType : Ti.UI.KEYBOARD_DEFAULT,
		returnKeyType : Ti.UI.RETURNKEY_DEFAULT,
		borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
		autocorrect : false,
		font : {
			fontFamily : 'Helvetica Neue',
			fontWeight : 'bold',
			fontSize : 20
		}
	});

	_resetPasswordControls.baseControl.passwordSection.add(_resetPasswordControls.baseControl.passwordLabel);
	_resetPasswordControls.baseControl.passwordSection.add(_password);

	_resetPasswordControls.baseControl.add(_resetPasswordControls.baseControl.passwordSection);
};

var loginWindow = Ti.UI.createWindow({
	orientationModes : [Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT, Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT]
});

var loginButton = Ti.UI.createButton({
	title : "Login",
	width : 169,
	height : 35
});

loginButton.addEventListener('click', resetPasswordShow);

loginWindow.add(loginButton);

loginWindow.open();

Comments

  1. Sabil Rahim 2013-06-17

    MASTER PR : https://github.com/appcelerator/titanium_mobile/pull/4396
  2. Pragya Rastogi 2013-10-23

    Verified Fix with: OSX: 10.8.5 Xcode:5.0 Appcelerator Studio: 3.2.0.201310230601 SDK:3.2.0.v20131022171645 acs:1.0.7 alloy:1.2.2 npm:1.3.2 titanium:3.2.0 titanium-code-processo:1.0.3 Device: ipad 7.0

JSON Source