Titanium JIRA Archive
Appcelerator Community (AC)

[AC-4574] Removing webviews from parent views crashes app

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2016-10-24T21:17:41.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsdefect, ios, iphone
ReporterUhlig Mobile
AssigneeShak Hossain
Created2016-10-21T16:24:15.000+0000
Updated2016-10-24T21:17:41.000+0000

Description

When navigating from a view back to another view, if you try and remove a webview from the view you are leaving, the app freezes and then eventually crashes. Test Case:
index.js

var button1 = Ti.UI.createButton({
	height: 50,
	width: 100,
	backgroundColor: '#00FF00',
	color: '#FFF',
	top: 50, 
	title: 'Get View'
});

var firstView = Ti.UI.createView({
	backgroundColor: '#CFCFCF'
});

var button2 = Ti.UI.createButton({
	backgroundColor: '#000',
	color: '#FFF',
	height: 50,
	width: 100,
	title: 'Get WebView'
});

var secondView = Ti.UI.createView();

var button3 = Ti.UI.createButton({
	backgroundColor: '#0000FF',
	color: '#FFF',
	height: 50,
	width: 100,
	top: 60,
	title: 'Go Back'
});

button3.addEventListener( 'click', function( e ) {
	var items = firstView.children;
	
	for( var i = 0; i<=items.length; i++ ){
		firstView.remove( items[ i ] );
		items[ i ] = null;
	}
});

var webView = Ti.UI.createWebView({
	height : Titanium.UI.SIZE,
	width : '100%',
	top: 20,
	contentHeight : Ti.UI.SIZE,
	bottom : 0,
	font : Alloy.CFG.FONT_14,
	color : '#666',
	ignoreSslError : true,
	html: '<b>This is only a test. Do not be alarmed.</b>'
});

secondView.add(webView);
secondView.add(button3);

button2.addEventListener( 'click', function( e ) {
	firstView.add(secondView);
});

firstView.add( button2 );

button1.addEventListener( 'click', function( e ) {
	$.testView.add( firstView );
});

$.testView.add( button1 );

$.index.open();
Process to create bug: 1) Click 'Get View' button 2) Click 'Get WebView' button 3) Click 'Go Back' button 4) Now, click 'Get WebView' button again and app will freeze and then eventually crash. I cannot reproduce this issue on Android, only iOS.

Comments

  1. Uhlig Mobile 2016-10-21

    This is the same issue as AC-4560 but that was marked resolved so I entered another one with the JS being in one file.
  2. Sharif AbuDarda 2016-10-24

    Hello, Your other ticket is open. Follow guide in there. You haven't provide a full sample code. Please provide a full sample code that regenerated the issue. In here the code you provided "testView" is not defined. Please provide the test-case in a single JS file so it can be debugged better. But there are some problems with your code as well, for example you are firing the "open" event manually. This is fired by the system. You are also trying to use an open event to a view, but they are only used for window instances. We can validate the issue after the single-file test-case is available, thx!. Please provide the requirements in there. Closing this as duplicate. Thanks.

JSON Source