Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27293] Android: HTTPClient onsendstream "progress" is always set to 1.0

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2019-10-30T18:22:42.000+0000
Affected Version/sRelease 5.1.2, Release 8.0.2
Fix Version/sRelease 8.3.0
ComponentsAndroid
Labelsandroid, engSchedule, httpclient
ReporterRene Pot
AssigneeYordan Banev
Created2015-12-16T14:08:50.000+0000
Updated2019-10-30T18:22:42.000+0000

Description

When initiating an XHR request on Android, and providing the onsendstream callback function, the progress within the payload (e.progress) will always be 1. Expected is the actual progress as a number between 0.0 and 1.0

Comments

  1. Sharif AbuDarda 2015-12-17

    Hello [~topener], Please provide a complete test case which demonstrate your problem. We will try to regenerate the issue. Also please provide the log and your full configuration. Make sure you follow the [documentation](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Network.HTTPClient-property-onsendstream) of uploading file. Thanks.
  2. Anna 2016-03-01

    I'm still having this problem in Ti SDK 5.1.2.GA
  3. Anna 2016-03-03

    Reopen this ticket please, it doesn't work now
  4. Daniel Ethier 2017-04-16

    I am seeing this issue as well. I will see if I can come up with a simple example. I believe I am following the documentation (setting onsendstream before calling open, is there something else?). Please re-open. I am using SDK 6.0.3 ...
  5. ACI Informatica 2019-07-23

    I can reproduce with this code and Ti SDK 8.0.2 (an 1+ MB image in assets/images folder is required to test or just use an equivalent size string):
       var win = Ti.UI.createWindow();
       var progress = Ti.UI.createProgressBar({
             width:200,
             min:0,
             max:1,
             value:0,  
             tintColor : "red"
       });
       win.add(progress);
       
       var timestamp = Date.now();
       var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, '/images/img.jpg'); // app/assets/images/img.jpg
       var base64String = Ti.Utils.base64encode(file).toString();
       
       win.addEventListener('open', function() {
       	var xhr = Ti.Network.createHTTPClient({
       		onload : function() {
       			var time_passed = Math.floor((Date.now() - timestamp) / 1000);
       			Ti.API.info('Seconds passed:', time_passed, 'SUCCESS');
       		},
       		onsendstream : _.throttle(function(e) {
       			var time_passed = Math.floor((Date.now() - timestamp) / 1000);
       			Ti.API.info('Seconds passed:', time_passed + ', progress:', e.progress);
       			progress.setValue(e.progress);
       		}, 250)
       	});
       	xhr.open('POST', 'https://httpbin.org/post');
       	xhr.send(base64String);
       });
       
       win.open();
       
  6. Sharif AbuDarda 2019-07-29

    Hello [~jquick], The issue is reproducible with SDK 8.0.2.GA. With the above sample code and a >1MB image file in the assets/android/images/ directory the progress always shows 1. And after sometime it shows success. Thanks.
       [INFO]  Seconds passed: 1, progress: 1
       [INFO]  Seconds passed: 1, progress: 1
       [INFO]  Seconds passed: 1, progress: 1
       [INFO]  Seconds passed: 3, progress: 1
       [INFO]  Seconds passed: 3, progress: 1
       [INFO]  Seconds passed: 3, progress: 1
       [INFO]  Seconds passed: 3, progress: 1
       [INFO]  Seconds passed: 4, progress: 1
       [INFO]  Seconds passed: 4, progress: 1
       [INFO]  Seconds passed: 23 SUCCESS
       
  7. Yordan Banev 2019-08-22

    PR: https://github.com/appcelerator/titanium_mobile/pull/11168
  8. Satyam Sekhri 2019-09-18

    FR passed.
  9. Christopher Williams 2019-10-02

    Moving back out of QE test, because unit tests fail with this PR.
  10. Christopher Williams 2019-10-21

    merged to master
  11. Satyam Sekhri 2019-10-30

    Verified on: Mac OS 10.14.6 Ti SDK: 8.3.0.v20191030085531 Appc CLI: 7.1.1 Node: 10.5.0 JDK: 1.8.0_162 Studio: 5.1.4.201909061933 Device: Nexus4 (v5.1.1), Pixel3(v10.0) emulator

JSON Source