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

Android: HTTPClient downloads are slower compared to iOS

    Details

    • Story Points:
      5
    • Sprint:
      2016 Sprint 17 SDK

      Description

      Performance of HTTP Client on Android is rather sub-par when compared to how it performs on iOS. Speed and responsiveness is just not there and has never been. It also seems to be hard on resources that can really slow down the performance of the phone/app as a whole when there are multiple HTTP requests happening at once or in succession.

      Here is a basic bit of code that just does a download of a 100 Mb file and shows the speed of the download and time. In the image attached you can see the performance difference between a iPhone and Android phone running the same app. The android phone is more the capable of the same download speed as the iPhone is showing, when using react or when creating a web view to do the same thing I can get over 150 Mbps on the Android phone.

      Sample code:

      var xhr = null;
       
      var win = Ti.UI.createWindow({
        backgroundColor: '#fff',
        fullscreen: false, navBarHidden: true, exitOnClose: true, theme: "Theme.materialTheme", orientationModes: [Titanium.UI.PORTRAIT]
      });
       
      var runTime = Ti.UI.createLabel({
        text: 'Run Time...',
        top: 50,
        left: 10,
        color: '#000'
      });
       
      var downloadSpeed = Ti.UI.createLabel({
        text: '0.00 Mbps',
        top: 90,
        left: 10,
        color: '#000'
      });
       
       
      var buttonStart = Ti.UI.createButton({ title: "START", width: 100, height: 40, top: '45%', left: '10%' });
      var buttonStop = Ti.UI.createButton({ title: "STOP", width: 100, height: 40, top: '45%', right: '10%' });
       
       
      buttonStart.addEventListener("click", function() {
       
        var startTime = new Date().getTime();
        var totalPercent = 0;
       
        xhr = Titanium.Network.createHTTPClient({
          ondatastream: function(e) {
            totalPercent = (e.progress).toFixed(2);
            var currentTime = new Date().getTime();
            var timeDiff = ((currentTime-startTime)/1000).toFixed(2);
            var totalDownloaded = (102400 * totalPercent);
            var currentKBPS = (((((totalDownloaded * 1024) * 8.192) / timeDiff) / 1024 / 1024)).toFixed(2);
       
            runTime.text = timeDiff;
            downloadSpeed.text = currentKBPS + ' Mbps';
          },
          onload: function() {
            alert('All Finished!');
          },
          timeout: 10000
        });
       
        xhr.open('GET','http://mirror.lstn.net/st/test100.zip');
        xhr.send();
       
      });
       
       
      buttonStop.addEventListener("click", function() {
        xhr.abort();
      });
       
       
      win.add(runTime);
      win.add(downloadSpeed);
      win.add(buttonStart);
      win.add(buttonStop);
      win.open();
      

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              dlewis23 Donovan Lewis
              Reviewer:
              Gary Mathews
            • Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • It looks like Backbone Issue Sync is not enabled for your project.

                  Git Source Code