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

Android HTTPClient onsendstream progress is wrong

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: Release 5.2.0
    • Fix Version/s: Release 6.1.0
    • Component/s: Android
    • Labels:
    • Environment:

      Titanium SDK 5.1.2, 5.2.0

    • Story Points:
      8
    • Sprint:
      2016 Sprint 13 SDK, 2016 Sprint 21 SDK

      Description

      I've noticed that the progress callback of TiHTTPClient under Android reaches a value of 1 way before the upload is completed. This can be seen on slow link speeds. I believe this bug also exists on normal speeds but is less apparent there.

      This might be related to https://jira.appcelerator.org/browse/TC-5837

      I've tested this with Titanium SDK 5.1.2 & 5.2.0 on Android 4, 5 and 6 devices. For testing I limited my wireless link speed with dd-wrt to 64kbits. This is also reproducable with slow mobile EDGE speeds.

      The example code uses a 1 MB testfile from here: http://cachefly.cachefly.net/speedtest/

       
      	var win = Ti.UI.createWindow();
      	var progress = Ti.UI.createProgressBar({
      		width:200,
      		min:0,
      		max:1,
      		value:0,	
      	});
      	win.add(progress);
       
      	var timestamp = Date.now();
      	var file = Ti.Filesystem.getFile('1mb.test');
       
      	win.addEventListener('open', function() {
      		var xhr = Ti.Network.createHTTPClient({
      			onload: function() {
      				var time_passed =  Math.floor((Date.now()-timestamp)/1000);
      				Ti.API.info(time_passed + ' SUCCESS');
      			},
      			onsendstream: function(e) {
      				var time_passed =  Math.floor((Date.now()-timestamp)/1000);
      				Ti.API.info(time_passed + ' PROGRESS ' + e.progress);
      				progress.setValue(e.progress);
      			}
      		});
      		xhr.open('POST', 'http://www.example.org/post.php');
      		xhr.send({data: file})
      	});
      	win.open();
      
      

      What should happen:
      The link speed IS constant, so the progress log should be liniear. Assuming a BLANK response, the onload event should get called quickly after progress reached the value of 1.

      What actually happens:
      Progress goes up to value 1 very quickly (in 1-2 seconds). It's not possible to upload 1MB in ~1 second with the available bandwidth. The progress is not fired anymore after it reached the value of 1 although the upload is still in progress. After ~138 seconds the onload event fires correctly. The time of the onload event is consistent with the available bandwith. Router bandwith logs show also that a upload is in progress until the onload event is fired.

      [INFO] :   0 PROGRESS 0.00048828125
      [INFO] :   0 PROGRESS 0.0009765625
      [INFO] :   0 PROGRESS 0.00146484375
      [INFO] :   0 PROGRESS 0.001953125
      [INFO] :   0 PROGRESS 0.00244140625
      ...
      [INFO] :   1 PROGRESS 0.99853515625
      [INFO] :   1 PROGRESS 0.9990234375
      [INFO] :   1 PROGRESS 0.99951171875
      [INFO] :   1 PROGRESS 1
      [INFO] :   138 SUCCESS
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                l0wb1rd Low Bird
                Tester:
                Abir Mukherjee
              • Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Source Code