{ "id": "155096", "key": "TIMOB-20483", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "17608", "name": "Release 6.1.0", "archived": false, "released": true, "releaseDate": "2017-05-26" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-10-20T22:56:26.000+0000", "created": "2016-02-24T12:40:23.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android" ], "versions": [ { "id": "16997", "name": "Release 5.2.0", "archived": false, "released": true, "releaseDate": "2016-02-23" } ], "issuelinks": [ { "id": "52580", "type": { "id": "10122", "name": "Gantt: start-finish", "inward": "is triggered by", "outward": "is triggering" }, "outwardIssue": { "id": "162924", "key": "TIMOB-23852", "fields": { "summary": "Android: http status code 411 error when building a default app with ti.cloud module", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "53552", "type": { "id": "10122", "name": "Gantt: start-finish", "inward": "is triggered by", "outward": "is triggering" }, "outwardIssue": { "id": "164616", "key": "TIMOB-24177", "fields": { "summary": "Android : TiHTTPClient / Request Length Expected Wrong (6.1.0 regression)", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "51745", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "160350", "key": "TIMOB-23409", "fields": { "summary": "Android: onsendstream progress is wrong", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-02-02T23:22:37.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "attachment": [], "flagged": false, "summary": "Android HTTPClient onsendstream progress is wrong", "creator": { "name": "l0wb1rd", "key": "l0wb1rd", "displayName": "Low Bird", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "l0wb1rd", "key": "l0wb1rd", "displayName": "Low Bird", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK 5.1.2, 5.2.0", "closedSprints": [ { "id": 649, "state": "closed", "name": "2016 Sprint 13 SDK", "startDate": "2016-06-18T00:25:17.303Z", "endDate": "2016-07-02T00:25:00.000Z", "completeDate": "2016-07-04T04:25:16.889Z", "originBoardId": 114 }, { "id": 733, "state": "closed", "name": "2016 Sprint 21 SDK", "startDate": "2016-10-08T00:53:00.000Z", "endDate": "2016-10-22T00:53:00.000Z", "completeDate": "2016-10-24T03:58:08.547Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "385888", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "Had the same issue when trying to upload a 3-5MB file with a self-build 5.4.0 git version. Progress was at 100% but the upload still took some time before onLoad was called. I thought it was my server who is not responding correctly. But it looks exactly like the issue you are describing. ", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-05-17T09:25:11.000+0000", "updated": "2016-05-17T09:25:11.000+0000" }, { "id": "385890", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "Did some testing and found a solution:\r\n\r\nhttps://developer.android.com/reference/java/net/HttpURLConnection.html\r\n\r\n\r\n{noformat}\r\nTo upload data to a web server, configure the connection for output using setDoOutput(true).\r\n\r\nFor best performance, you should call either setFixedLengthStreamingMode(int) when the body length is known in advance, or setChunkedStreamingMode(int) when it is not. Otherwise HttpURLConnection will be forced to buffer the complete request body in memory before it is transmitted, wasting (and possibly exhausting) heap and increasing latency. \r\n{noformat}\r\n\r\nSo adding {{client.setChunkedStreamingMode(0);}} below {{client.setDoOutput(true);}} and adding {{setRequestHeader(\"Transfer-Encoding\",\"chunked\");}} in TiHTTPClient.java fixed the problem. But I need to do some more testing before creating a PR", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-05-17T10:37:10.000+0000", "updated": "2016-05-17T10:37:10.000+0000" }, { "id": "385899", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/8003\r\n\r\nI've tried to use setFixedLengthStreamingMode(totalLength) but it seems that it is not the total length of the whole request. Some bytes where missing and it led to an error. So I stick to setChunkedStreamingMode() with a default value of 1024 (1kb) as mentinoned in different postings e.g. http://stackoverflow.com/a/26730636/5193915\r\n\r\nUsing the example code above worked fine with a 5MB file: progress and onload are in sync", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-05-17T12:56:14.000+0000", "updated": "2016-05-17T12:56:14.000+0000" }, { "id": "385919", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~michael] Thank you so much for the investigation and PR. I've yet to check setChunkedStreamingMode more but is there any downside to using that?", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-05-17T17:16:02.000+0000", "updated": "2016-05-17T17:16:02.000+0000" }, { "id": "385930", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "@msamah as far as I read it will disable the internal buffering (which is the problem in the current upload process) of the file in memory. And since Google recommends this as \"best performance\" in their docs it might be a good idea :) But I'm not 100% sure if there are side-effects with different servers. I've tested it with a apache/php host with a basic {{move_uploaded_file()}} function\r\n", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-05-17T18:51:27.000+0000", "updated": "2016-05-17T18:51:27.000+0000" }, { "id": "385983", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "(y)", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-05-18T03:08:57.000+0000", "updated": "2016-05-18T03:08:57.000+0000" }, { "id": "386046", "author": { "name": "l0wb1rd", "key": "l0wb1rd", "displayName": "Low Bird", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I can confirm that adding client.setChunkedStreamingMode(1024); fixes the issue. Thank you Michael G!\r\n\r\nHowever, I believe the root cause for all this is that the calculation of totalLength is wrong. Maybe it's worth to figure out why this is happening aswell...", "updateAuthor": { "name": "l0wb1rd", "key": "l0wb1rd", "displayName": "Low Bird", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-05-18T11:40:10.000+0000", "updated": "2016-05-18T11:40:10.000+0000" }, { "id": "386134", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-05-19T02:22:35.000+0000", "updated": "2016-05-19T02:22:35.000+0000" }, { "id": "389099", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Tested with :\r\n{code}\r\n \r\n var win = Ti.UI.createWindow();\r\n var progress = Ti.UI.createProgressBar({\r\n width:200,\r\n min:0,\r\n max:1,\r\n value:0, \r\n });\r\n win.add(progress);\r\n \r\n var timestamp = Date.now();\r\n var file = Ti.Filesystem.getFile('1mb.mp4');\r\n \r\n win.addEventListener('open', function() {\r\n var xhr = Ti.Network.createHTTPClient({\r\n onload: function() {\r\n var time_passed = Math.floor((Date.now()-timestamp)/1000);\r\n Ti.API.info(time_passed + ' SUCCESS');\r\n },\r\n onsendstream: function(e) {\r\n var time_passed = Math.floor((Date.now()-timestamp)/1000);\r\n Ti.API.info(time_passed + ' PROGRESS ' + e.progress);\r\n progress.setValue(e.progress);\r\n }\r\n });\r\n xhr.open('POST', 'https://httpbin.org/post');\r\n xhr.send({data: file})\r\n });\r\n win.open();\r\n\r\n\r\n{code} \r\nWith url to httpbin to make sure it works.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-06-27T06:51:12.000+0000", "updated": "2016-06-27T06:51:12.000+0000" }, { "id": "389100", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/8003 has been reviewed and merged into master", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-06-27T06:53:49.000+0000", "updated": "2016-06-27T06:53:49.000+0000" }, { "id": "389260", "author": { "name": "max87", "key": "max87", "displayName": "Marian Kucharcik", "active": true, "timeZone": "Europe/Prague" }, "body": "Hi guys,\r\nis there any way for me to test it as ? Is it part of any continous build available yet?\r\nThank you", "updateAuthor": { "name": "max87", "key": "max87", "displayName": "Marian Kucharcik", "active": true, "timeZone": "Europe/Prague" }, "created": "2016-06-28T14:39:36.000+0000", "updated": "2016-06-28T14:39:36.000+0000" }, { "id": "389272", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "sure: http://builds.appcelerator.com.s3.amazonaws.com/index.html#master", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-06-28T16:15:12.000+0000", "updated": "2016-06-28T16:15:12.000+0000" }, { "id": "389571", "author": { "name": "max87", "key": "max87", "displayName": "Marian Kucharcik", "active": true, "timeZone": "Europe/Prague" }, "body": "Hi Michael,\r\nthanks for link, I installed latest sdk v.6.0.0.v20160629231945 from Wed Jun 29, 2016 11:19:45 PM but I'm still facing error with ondatastream progress. \r\nI use Ti.Media.showCamera() to take a picture and in success event I use a JSONRPC module(https://github.com/wiistriker/Titanium-JSONRPC-Client, it uses basic xhr requests) to upload that picture to server. I create callback for onsendstream to log progress, but it logs 1 for many times(not usual float number progress).\r\nI updated node.js to v6.2.2, cleaned project and run fresh build.\r\nCan you please help me?\r\nThank you", "updateAuthor": { "name": "max87", "key": "max87", "displayName": "Marian Kucharcik", "active": true, "timeZone": "Europe/Prague" }, "created": "2016-06-30T11:17:37.000+0000", "updated": "2016-06-30T11:17:37.000+0000" }, { "id": "393563", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\n\r\nThe {{onLoad()}} callback gets called within a 1-2 seconds after download gets completed.\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.7.0.201607250649\r\nTi SDK : 6.0.0.v20160817065403\r\nTi CLI : 5.0.9\r\nAlloy : 1.9.1\r\nMAC El Capitan : 10.11.6\r\nAppc NPM : 4.2.7\r\nAppc CLI : 6.0.0-24\r\nNode: 4.4.4\r\nNexus 6 - Android 6.0.1", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-08-19T00:44:47.000+0000", "updated": "2016-08-19T00:44:47.000+0000" }, { "id": "395006", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Had to reopen and undo this due to this fix causing TIMOB-23852.\r\n\r\nThis needs to be revisited.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-09-01T04:11:53.000+0000", "updated": "2016-09-01T04:11:53.000+0000" }, { "id": "396659", "author": { "name": "max87", "key": "max87", "displayName": "Marian Kucharcik", "active": true, "timeZone": "Europe/Prague" }, "body": "Hi guys,\r\nany news on this?\r\nThanks", "updateAuthor": { "name": "max87", "key": "max87", "displayName": "Marian Kucharcik", "active": true, "timeZone": "Europe/Prague" }, "created": "2016-09-20T14:33:57.000+0000", "updated": "2016-09-20T14:33:57.000+0000" }, { "id": "396763", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~max87] Sorry. This had to be reopened to be revisited. It's not lined up for any sprint yet.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-09-21T02:16:49.000+0000", "updated": "2016-09-21T02:16:49.000+0000" }, { "id": "399228", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "master: https://github.com/appcelerator/titanium_mobile/pull/8522", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-10-18T12:40:14.000+0000", "updated": "2016-10-18T12:40:14.000+0000" }, { "id": "402515", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~gmathews], I am seeing some difference between the time the progress bar fills up & I see the success.\r\nFor a 5MB file the difference is 14 sec.\r\nFor a 20 MB file the difference is 50 sec :\r\n{code}\r\n[INFO] : 12 PROGRESS 0.9999000627871563\r\n[INFO] : 12 PROGRESS 0.999924370555791\r\n[INFO] : 12 PROGRESS 0.9999486783244256\r\n[INFO] : 12 PROGRESS 0.9999729860930603\r\n[INFO] : 12 PROGRESS 0.999997293861695\r\n[INFO] : APSAnalyticsService: Analytics Service Started\r\n[INFO] : APSAnalyticsService: Stopping Analytics Service\r\n[INFO] : 69 SUCCESS\r\n{code}\r\n\r\nI don't think this is acceptable. \r\n\r\nAppc Studio : 4.8.1.201611291132\r\nSDK Version : 6.1.0.v20161202104721\r\nMac OS Version : 10.12\r\nXcode Version : Xcode 8.1 Build version 8B62\r\nAppc CLI AND Appc NPM : {\"NPM\":\"4.2.9-1\",\"CLI\":\"6.1.0-302\"}\r\nTi CLI : 5.0.11\r\nAlloy : 1.9.4\r\nNode : v4.6.0\r\nDevice: running 7.1Pixel\r\n", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-12-03T01:12:16.000+0000", "updated": "2016-12-03T01:12:45.000+0000" }, { "id": "406189", "author": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested with this environment:\r\nNPM Version: 2.15.9\r\nNode Version: 4.5.0\r\nMac OS: 10.12.1\r\nAppc CLI: 6.1.0\r\nAppc CLI NPM: 4.2.8\r\nTitanium SDK version: 6.1.0.v20170202120400\r\nAppcelerator Studio, build: 4.8.1.201612050850\r\nAndroid Device: 6.0.1\r\n\r\nI tested this with SDK 6.0.0.GA, and found that a 16 Mb file took about 15 seconds to upload, while the progress bar hit \"1\" at about 8 seconds. With SDK 6.1.0, the upload was approximately 12 seconds, while the progress bar hit \"1\" at 10 seconds. The variability in upload time is likely due to variability due to the Wi-Fi connection. I tested this several times, and I consistently found that upload completion was with 2-3 seconds after the progress bar hit \"1\".", "updateAuthor": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-02-02T23:22:14.000+0000", "updated": "2017-02-02T23:22:14.000+0000" } ], "maxResults": 24, "total": 24, "startAt": 0 } } }