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

iOS: Aborting upload causes file to stay in RAM

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: Release 3.4.0
    • Fix Version/s: Release 4.0.0
    • Component/s: iOS
    • Environment:

      OS X 10.10 Titanium Studio, build: 3.4.0.201409161931 iOS 8 xCode 6

      CLI version 3.4.0-beta,
      Titanium SDK version 3.4.0.v20140905152516
      iOS 8.0. Device iPod 5G 8.0.

    • Story Points:
      8
    • Sprint:
      2014 Sprint 24 SDK

      Description

      Problem Description

      When aborting a file upload the file that was loaded into ram is kept in ram. The ram does not get cleared unless the upload is completed. So every file thats uploaded and aborted is being kept in active ram on the device.

      If a user uploads a file and aborts the upload multiple times ram usage becomes very high and will cause the app to crash. This did not happen with release-3.2.3 the ram would get cleared when the upload was aborted.

      When watching instruments while preforming a upload you can watch ram using spike on each upload but never be released.

      Steps to reproduce

      1. Create new mobile project (classic titanium)
      2. Please copy the Attached file to the Resources directory.
      3. Paste the Sample Code to app.js ( to test with large upload file that will automatically abort after 2.5 seconds) :

      app.js

      var win = Titanium.UI.createWindow({backgroundColor:'#fff',layout:'vertical'});
       
      var ind = Titanium.UI.createProgressBar({
          width:200,
          height:50,
          min:0,
          max:1,
          value:0,
          top:10,
          message:'Progress',
          font:{fontSize:12, fontWeight:'bold'},
          color:'#888'
      });
       
      win.add(ind);
      ind.show();
       
      addButton({
          title: 'Upload File',
          callback: function(e) {
              ind.value = 0;
       
       		var canceled = false;
              var file = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'sunset.jpg');
              var uploadfile = file.read();
       
              var httpClient = Titanium.Network.createHTTPClient(); 
              httpClient.setTimeout(12000);
       
              var uploadStartTime = new Date().getTime();
       
              httpClient.onsendstream = function(e){ 
                  ind.value = e.progress;
                  // The upload is cancelled at 25%
                  if (e.progress >= 0.25) {
                  	httpClient.abort();
                  	httpClient = null;
                  }
              };
       
              httpClient.open('POST', 'http://cachefly.cachefly.net'); 
              httpClient.send({media:uploadfile});
          }
      });
       
      addButton({
          title: 'Open Window',
          callback: function(e) {
              openWindow();
          }
      });
         
      function addButton(args) {
          var b1 = Ti.UI.createButton({
              title: args.title,
              top: 40
          });
          b1.addEventListener('click', args.callback);
          win.add(b1);
      }
        
      function openWindow() {
          var win2 = Ti.UI.createWindow({
              backgroundColor: 'blue',
              layout:'horizontal'
          });
          for (var i=0;i<500;i++) {
              var v = Ti.UI.createView({
                  backgroundColor: 'red',
                  height: 50, width: 50,
                  top:5, left:5
              });
       
              var l = Ti.UI.createLabel({text: i})
              v.add(l);
              win2.add(v);
          }
          win2.addEventListener('click', function() {
              win2.close();
          });
          win2.open();
      }
       
      win.open();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jalter Jon Alter
                Reporter:
                dlewis23 Donovan Lewis
                Reviewer:
                Muhammad Dadu (Inactive)
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Source Code