Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25941] Android: HTTPClient downloads are slower compared to iOS

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-08-24T21:22:18.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.3.1
ComponentsAndroid
Labelsandroid, httpclient, performance
ReporterDonovan Lewis
AssigneeJoshua Quick
Created2018-01-24T16:51:45.000+0000
Updated2018-08-27T12:52:24.000+0000

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

FileDateSize
IMG_1279.jpg2018-01-24T16:42:49.000+00001010089
IMG_1281.jpg2018-01-24T17:19:18.000+00001615235

Comments

  1. Jason Kneen 2018-01-24

    Is it consistently slower? Can you try a speedtest app / speedcheck app on both devices to see what throughput you're getting? My concern is that these are two different devices on a network -- and whilst they should both be fast, it's not a great test because one could (for some reason) be accessing the network more slowly. Have you tried running simulator and emulator on the *same* host machine -- so both are piggy backing the same wifi / hard-wired connection. Obviously they'd be some differences still between emulator / simulator etc, but the network connection should be the same for both so might be a better test.
  2. Donovan Lewis 2018-01-24

    Jason, Yes it is consistently slower. I attached another screen shot showing both devices after running a speed test. The Android phone is a Ti app with the speed test taken in a web view. One after the other the test was not performed at the same time. In this case they are both using 802.11ac using the same wifi and the Android phone is not some old slow phone. With no other apps running in the background. Its not just this device, it doesn't matter what Android device I use I have had this issue since the first day I have used Ti. I have 7 Android phones on my desk right now running all different versions of Android. I also run my own speed test app and I can tell you that this has been a problem for a very long time. The Android HTTPClient just doesn't perform well. It doesn't matter if its running in the emulator or simulator what phone I'm using, the same code on Android will always be many times slower then the same on iOS. If I run multiple HTTPClients at once to do a threaded test the issue is magnified many times over. It's also not like we are talking a 5 or 10 Mbps difference here, its a 100+ Mbps difference just on that single threaded test. !IMG_1281.jpg|thumbnail!
  3. Jason Kneen 2018-01-24

    OK good to know, thanks
  4. Mostafizur Rahman 2018-04-03

    Hello [~dlewis23], Are you still having the issue?Just following up to check the status of this issue and if you need further help on it.  Please let us know.  Thanks
  5. Donovan Lewis 2018-04-04

    Yes Mostafizur Rahman, I am still having exactly the same problem. Nothing has changed or gotten better.
  6. Sharif AbuDarda 2018-04-06

    Hello, I am not able to reproduce the issue as described. I tested the issue in emulator and simulator. My observation is, for the simulator the starting speed is a bit high like 50MBps it shows and for the emulator, it's 39MBps. But, both of them, it does come at a steady speed of 30 odd MBps after some seconds. So, I also think this is a device issue, not the Http client itself. Thanks.
  7. Rene Pot 2018-04-06

    Tried testing too, on emulator/simulator that is. I get the same results for iOS & Android (both around 40-50mbit, where a speedtest shows 200). Tried a more local source of a 100mb file and that results in similar speed for both platforms too. [~dlewis23] Is this device only or do you have it on emulator too?
  8. Donovan Lewis 2018-04-06

    Yes of course I see this in the emulator. But the emulator is irrelevent because people aren't running my apps in the emulator his happens on all devices that I test on. It happens on everything from a LG G2 all the way to a Samsung Galaxy S8 and Google Pixel 2 XL. It happens on all. And the problem gets magnified as you run multiple threads as I'm trying to do. *Your also not going fast enough to see the problem.* You should be much faster than 40 - 50 Mbps, especially if a speed test shows your internet speed as 200 Mbps. Please change the 100 mb download file its using to the closest one to you from the list here to eliminate any routing/distance factors of download speed : https://www.linode.com/speedtest It doesn't matter if its in emulator/simulator or on device I get the same poor performance on android no matter what device vs iOS. An example right now that I just did, I get from the Linode Atlanta test file over 300 Mbps from a single stream on a iPhone X and around 140 on a Galaxy S8 or Pixel 2 XL. Both of those phones should be as fast or faster because of there better antenna design. And if I build with React or do a simple web view I get the same performance as the iPhone X I build with TI and its half. If I add multiple threads the problem gets worse as you take more tests.
  9. Joshua Quick 2018-08-21

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10274
  10. Donovan Lewis 2018-08-22

    Been testing the PR and so far its much better from the little bit of testing I have done on a Galaxy S8 or older Moto phone. Results in faster speeds and much more consistent results. I would say so far its quite good and not sure if it needs to wait till 7.5.0 to be released. If anything else changes in my testing I will update.
  11. Joshua Quick 2018-08-24

    PR (7.4.x): https://github.com/appcelerator/titanium_mobile/pull/10283 PR (7.3.x): https://github.com/appcelerator/titanium_mobile/pull/10284
  12. Lokesh Choudhary 2018-08-24

    FR Passed. Waiting for CR to merge.
  13. Samir Mohammed 2018-08-27

    Verified fix in SDK version: 7.3.1.v20180824134723, 7.4.0.v20180824134643 and 7.5.0.v20180824145645. Test and other information can be found at: Master: https://github.com/appcelerator/titanium_mobile/pull/10274 7_3_X: https://github.com/appcelerator/titanium_mobile/pull/10284 7_4_X: https://github.com/appcelerator/titanium_mobile/pull/10283

JSON Source