Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-5465

iOS: Tapping Tab Orphans Windows on Tab's Stack

    Details

      Description

      Problem

      Tapping the tab's button to return to the root window of the tab orphans any windows between the current window and the root window.

      Why This Is A Problem

      Orphaned windows equate to leaked memory.

      Expected Behavior

      Tapping the tab's button should close every window that is open on that tab's stack, not just the current window.

      Reproduction

      Drop the following in an app.js. Touch "S1: Touch Me", then "S2: Touch Me". Notice in the log which windows were opened, and which were closed.

      app.js

      var tabGroup = Ti.UI.createTabGroup();
       
      function openWindowOnStack(i) {
          var win = Ti.UI.createWindow({
              title: 'I Am ' + i
          });
          win.addEventListener('open', function() {
              Ti.API.info('opened ' + i + '!');
              if (i < 4) {
                  openWindowOnStack(i + 1);
              }
          });
          win.addEventListener('close', function() {
              Ti.API.info('closed ' + i + '!');
          });
          tab.open(win);
      }
       
      var outer = Ti.UI.createWindow({
          title: 'I Am Parent',
          rightNavButton: Ti.UI.createButton({ title: 'S1: Touch Me' })
      });
      var tab = Ti.UI.createTab({
          window: outer, title: 'S2: Touch Me'
      });
      tabGroup.addTab(tab);
       
      outer.rightNavButton.addEventListener('click', function() {
          openWindowOnStack(0);
      });
       
      tabGroup.open();
      

      Current Output

      Current Output

      [INFO] opened 0!
      [INFO] opened 1!
      [INFO] opened 2!
      [INFO] opened 3!
      [INFO] opened 4!
      [INFO] closed 4!
      

      Expected Output

      Expected Output

      [INFO] opened 0!
      [INFO] opened 1!
      [INFO] opened 2!
      [INFO] opened 3!
      [INFO] opened 4!
      [INFO] closed 3!
      [INFO] closed 2!
      [INFO] closed 1!
      [INFO] closed 0!
      

        Attachments

          Activity

            People

            • Assignee:
              stephentramer Stephen Tramer
              Reporter:
              dtoth Dawson Toth
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-4628
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code