Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8063] Android: Backing out of a window with its own activity while it's still opening leads to bad state.

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-03-17T19:25:46.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterJosh Roesslein
AssigneeJosh Roesslein
Created2012-03-16T13:44:42.000+0000
Updated2017-03-27T18:23:39.000+0000

Description

Windows which have their own activity and take a long time to open can crash the application if the user "backs" out of the new activity before the window has finished opening. This is mostly seen on emulator which runs into the global reference count limit due to a large number of Phantom references which build up.

Test case: Opening a window with a high number of child views.

This test case is taken from TIMOB-7897 and demonstrates the issue nicely. Run the application in the emulator. Click the button to load a new window with a large number of views. Notice the new activity becomes active (black screen). Hit the back button before the window finishes opening. Repeat this process until you crash the application due to the global reference limit being reached.
function mainViews() {
    
    var newWin = Ti.UI.createWindow({ navBarHidden: true });
    
    Ti.API.info('****** mainViews function has started ******');
    var views =[];
    var view = null;
    for (var i=0; i < 500; i++) {
        view = Ti.UI.createView();
        views.push(view);
        newWin.add(view);
    }
    
    
    newWin.open();
    
    alert("You may click back now.");
    
    Ti.API.info('Titanium views created and added to array');
    Ti.API.info('****** mainViews function has stopped ******');
}

var win = Ti.UI.createWindow({
    backgroundColor: "white"
});

var button = Ti.UI.createButton({
    title: "create 5k views"
});
button.addEventListener("click", function(e) {
    mainViews();
    Ti.API.info('Available memory: ' + Ti.Platform.availableMemory);
});

win.add(button);
win.open();

Comments

  1. Josh Roesslein 2012-03-17

    Not seeing this issue anymore with latest master and updated test case (views reduced to 500).
  2. Lee Morris 2017-03-27

    Closing ticket as I am unable to reproduce this issue with the following environment; Pixel (7.1) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.3 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80

JSON Source