Details

    • Type: Improvement
    • Status: Open
    • Priority: High
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Android
    • Story Points:
      5

      Description

      The current implementation of removeAllChildren() creates a copy of all views and removes each view in a while loop.
      The people at Shockoe showed in a blog post that it takes up to 24 seconds to remove 1000 views with

      theWindow.removeAllChildren();
      

      Changing the TiViewProxy method to use the native ViewGroup.removeAllViews() would bring down delay below 100ms!

      Test app:
      https://github.com/bpulley/titanium-profiling can be used to test the behavior. Just run the "Remove views en masse" test.

      var win = Ti.UI.createWindow({
          backgroundColor: "white"
      });
       
      var view = Ti.UI.createView({
          top: 0,
          left: 0,
          right: 0,
          height: 100,
          layout: "horizontal"
      });
       
      var scrollview = Ti.UI.createScrollView({
          top: 100,
          left: 0,
          right: 0,
          height: 100,
          layout: "horizontal",
          type: "horizontal"
      });
       
      for (var i = 0; i < 100; i++) {
          var v = Ti.UI.createView({
              width: 10,
              height: 10,
              backgroundColor: "red",
              left: 10
          });
          view.add(v);
          v = null;
       
          var v2 = Ti.UI.createView({
              width: 10,
              height: 10,
              backgroundColor: "red",
              left: 10
          });
          scrollview.add(v2);
          v2 = null;
      }
       
      // Listview
       
      var listView = Ti.UI.createListView({
          top: 200,
          height: 100
      });
      var sections = [];
       
      var fruitSection = Ti.UI.createListSection({
          headerTitle: 'Fruits'
      });
      var fruitDataSet = [{
          properties: {
              title: 'Apple'
          }
      }, {
          properties: {
              title: 'Banana'
          }
      }, ];
      fruitSection.setItems(fruitDataSet);
      sections.push(fruitSection);
       
      var vegSection = Ti.UI.createListSection({
          headerTitle: 'Vegetables'
      });
      var vegDataSet = [{
          properties: {
              title: 'Carrots'
          }
      }, {
          properties: {
              title: 'Potatoes'
          }
      }, ];
      vegSection.setItems(vegDataSet);
      sections.push(vegSection);
       
      listView.sections = sections;
       
      var fishSection = Ti.UI.createListSection({
          headerTitle: 'Fish'
      });
      var fishDataSet = [{
          properties: {
              title: 'Cod'
          }
      }, {
          properties: {
              title: 'Haddock'
          }
      }, ];
      fishSection.setItems(fishDataSet);
       
      function onOpen(e) {
          var startTime = new Date();
          console.log("View length: " + view.getChildren().length);
          view.removeAllChildren();
          console.log("View after remove length: " + view.getChildren().length);
       
          console.log("ScrollView length: " + scrollview.getChildren().length);
          scrollview.removeAllChildren();
          console.log("ScrollView after remove length: " + scrollview.getChildren().length);
       
          console.log("ListView length: " + listView.getSections().length);
          listView.removeAllChildren();
          console.log("ListView after remove length: " + listView.getSections().length);
          
          var endTime = new Date();
      	var delta = endTime - startTime;
          alert('time ' + delta + 'ms');
      }
       
      win.add(listView);
      win.add(view);
      win.add(scrollview);
      win.addEventListener("open", onOpen);
      win.open();
      

      Ti SDK 5.2.2 = 4160ms (and listview.removeAllViews() is not working)
      Patched Version = 333ms (listview will be empty)

        Attachments

          Activity

            People

            • Assignee:
              msamah Ashraf Abu (Inactive)
              Reporter:
              michael Michael Gangolf
            • Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code