{ "id": "170938", "key": "TIMOB-25744", "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": "20115", "name": "Release 7.3.0", "archived": false, "released": true, "releaseDate": "2018-08-17" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-05-25T08:37:20.000+0000", "created": "2018-01-25T20:59:49.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "ios", "ipad", "iphone", "javascriptcore" ], "versions": [ { "id": "17609", "description": "", "name": "Release 7.0.0", "archived": false, "released": true, "releaseDate": "2017-12-07" }, { "id": "19988", "description": "", "name": "Release 7.0.1", "archived": false, "released": true, "releaseDate": "2017-12-21" } ], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-08-10T20:55:55.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "Doing a file upload with the createHTTPClient on iOS in TI SDK 7.x.x causes the file to stay in ram after the upload is completed or aborted. It does not get removed from ram as it should. When doing a large upload or multiple uploads this is a rather big problem because it can cause the app to crash or have a large ram usage as you can see from the screen shot. \r\n\r\nExample code is below, using a 100MB file will cause 400 + Mb of ram usage for 1 upload, this will then stay in ram, doing 3 uploads will cause the app to crash on a iPhone X. \r\n\r\nThe file should be removed from ram when the upload is completed or aborted, it use to do this in previous version of TI. \r\n\r\n{code:java}\r\nvar xhr = null;\r\n\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff',\r\n fullscreen: false, navBarHidden: true, exitOnClose: true, theme: \"Theme.materialTheme\", orientationModes: [Titanium.UI.PORTRAIT]\r\n});\r\n \r\nvar runTime = Ti.UI.createLabel({\r\n text: 'Run Time...',\r\n top: 50,\r\n left: 10,\r\n color: '#000'\r\n});\r\n\r\nvar uploadSpeed = Ti.UI.createLabel({\r\n text: '0.00 Mbps',\r\n top: 90,\r\n left: 10,\r\n color: '#000'\r\n});\r\n\r\n \r\nvar buttonStart = Ti.UI.createButton({ title: \"START\", width: 100, height: 40, top: '45%', left: '10%' });\r\nvar buttonStop = Ti.UI.createButton({ title: \"STOP\", width: 100, height: 40, top: '45%', right: '10%' });\r\n\r\nvar uploadfile = Ti.Filesystem.getFile(Ti.Filesystem.getResourcesDirectory(), \"100MB.bin\").read();\r\n\r\nbuttonStart.addEventListener(\"click\", function() {\r\n\r\n console.log('Starting Upload');\r\n\r\n var startTime = new Date().getTime();\r\n var totalPercent = 0;\r\n\r\n xhr = Titanium.Network.createHTTPClient();\r\n xhr.onsendstream = function(e){ \r\n console.log(e.progress);\r\n\r\n totalPercent = (e.progress).toFixed(2);\r\n var currentTime = new Date().getTime();\r\n var timeDiff = ((currentTime-startTime)/1000).toFixed(2);\r\n var totalDownloaded = (102400 * totalPercent);\r\n var currentKBPS = (((((totalDownloaded * 1024) * 8.192) / timeDiff) / 1024 / 1024)).toFixed(2);\r\n\r\n runTime.text = timeDiff;\r\n uploadSpeed.text = currentKBPS + ' Mbps';\r\n };\r\n\r\n xhr.onload = function(e) {\r\n\r\n };\r\n xhr.open('POST','http://sfo.veeapps.com/upload.php');\r\n xhr.send({media: uploadfile });\r\n \r\n});\r\n\r\n\r\nbuttonStop.addEventListener(\"click\", function() {\r\n xhr.abort();\r\n xhr = null;\r\n});\r\n\r\n\r\nwin.add(runTime);\r\nwin.add(uploadSpeed);\r\nwin.add(buttonStart);\r\nwin.add(buttonStop);\r\nwin.open();\r\n{code}", "attachment": [ { "id": "64797", "filename": "http-client-jscore-fixed.png", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-03T18:42:56.000+0000", "size": 6017, "mimeType": "image/png" } ], "flagged": false, "summary": "iOS: Uploaded file persists in memory when using JSCore", "creator": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "closedSprints": [ { "id": 1028, "state": "closed", "name": "2018 Sprint 09 SDK", "startDate": "2018-04-22T22:53:08.928Z", "endDate": "2018-05-06T22:53:00.000Z", "completeDate": "2018-05-07T00:02:15.883Z", "originBoardId": 114 }, { "id": 1018, "state": "closed", "name": "2018 Sprint 07 SDK", "startDate": "2018-03-25T21:59:36.637Z", "endDate": "2018-04-08T21:59:00.000Z", "completeDate": "2018-04-08T17:55:14.467Z", "originBoardId": 114 }, { "id": 1034, "state": "closed", "name": "2018 Sprint 10 SDK", "startDate": "2018-05-07T00:03:21.636Z", "endDate": "2018-05-21T00:03:00.000Z", "completeDate": "2018-05-20T20:54:58.928Z", "originBoardId": 114 }, { "id": 1035, "state": "closed", "name": "2018 Sprint 11 SDK", "startDate": "2018-05-20T20:57:43.542Z", "endDate": "2018-06-03T20:57:00.000Z", "completeDate": "2018-06-04T15:13:14.425Z", "originBoardId": 114 }, { "id": 1021, "state": "closed", "name": "2018 Sprint 08 SDK", "startDate": "2018-04-08T17:57:36.122Z", "endDate": "2018-04-22T17:57:00.000Z", "completeDate": "2018-04-22T22:51:19.120Z", "originBoardId": 114 }, { "id": 1008, "state": "closed", "name": "2018 Sprint 06 SDK", "startDate": "2018-03-11T22:18:04.396Z", "endDate": "2018-03-25T22:18:00.000Z", "completeDate": "2018-03-25T21:52:36.683Z", "originBoardId": 216 } ], "comment": { "comments": [ { "id": "433994", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey [~dlewis23], thanks for the ticket! Looking at the 7.0.0 changes, the only thing that might have affected this is that we moved from the custim TiJSCore to the built-in JavaScriptCore engine by default and from the custom kroll thread to the main-thread (for UI-operations) by default. So you can try to revert that change locally by doing the following in the tiapp.xml:\r\n{code:xml}\r\n\r\nfalse\r\n\r\nfalse\r\n{code}\r\nI suspect it's rather the JSCore change, but let us know!\r\n\r\n--- Update ---\r\n[~dlewis23] Update: Can you please try to replace [this files|https://www.dropbox.com/s/710zy2gtfo8h54p/libAPSHTTPClient-fixed.zip?dl=1] in:\r\n{code}\r\n~/Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/iphone/Classes/APSHTTPClient\r\n{code}\r\nand observe the memory with Instruments? I added a few enhancements that ensure that all post data is cleared after a request either completes or fails / aborts. While the memory will decline by half of the size after the abort immediately, the other half is GC'd ~ 10-20sec afterwards, as our APSHTTPClient runs on ARC and the memory is handled by iOS internally. \r\n\r\nSome visual context (an Instruments screenshot) is also attached to the ticket. If you can confirm that it works for you, we'll schedule it for 7.1.0 and I'll push the changes. Thanks for reporting this on our blog and keep up the feedback!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-03T11:11:11.000+0000", "updated": "2018-02-03T18:42:49.000+0000" }, { "id": "434002", "author": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hans, I just tried your updated files and it defiantly makes a difference. It's much better but still possible to get a high amount of ram usage but at the same time I can see it being much more active in removing the data from ram and was able to get it to clear what I think was all or almost all of the post data by using the app or doing more upload tests. So I would say thats a decent fix. I will keep testing it and update again shortly. But I would say its 90% good with those updated files. \r\n\r\nThat being said adding \"false\" to my tiapp.xml fixes the problem 100% on iOS 11. With that added to my tiapp.xml within 10 seconds or so of a upload being finished or aborted in my app the ram gets cleared fully. \r\n\r\nI will update again shortly if I notice anything else, it does seem like you did make a good fix tho, I really appreciate the work you did because downloading/uploading files is the core point of my app. \r\n", "updateAuthor": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-03T21:09:28.000+0000", "updated": "2018-02-03T21:09:28.000+0000" }, { "id": "434006", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks [~dlewis23]! So you still see a bit leaking? That was not the case during my tests. Please let me know if you can provide an Instruments trace log in case it's still leaking.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-03T21:46:30.000+0000", "updated": "2018-02-03T21:46:30.000+0000" }, { "id": "434050", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Btw, cool app :-) Would love to see that showcased somewhen.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-05T15:31:32.000+0000", "updated": "2018-02-05T15:31:32.000+0000" }, { "id": "434118", "author": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hans, I don't know if I would say its still leaking but some data defiantly still sticks around in ram for a while after but its nothing like what it was before trying with your updated ASPHTTPClient files. Currently I am running 8, 10MB uploads at once and when continuing to use the app it never goes to crazy high ram usage anymore with your updated files. \r\n\r\nIt seems to clear about half the ram after the upload finishes or is aborted and the important part for me at least is when I do a few tests in a row it will eventually clear it all or the majority of the ram use and I will be back to around 100 MB of ram usage for a running app. I think we should go with your fix as is and see if anything else changes unless you have any more ideas on improving it. \r\n\r\nHere is an instruments.trace if you still want to see, the app I as testing in this was Simple Speed: http://speedsmart.net/downloads/Instruments.trace.zip\r\n\r\n\r\n\r\n", "updateAuthor": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-06T18:43:12.000+0000", "updated": "2018-02-06T18:43:12.000+0000" }, { "id": "434120", "author": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "body": "And thank you, The app was showcased a long time ago when it was under a different name. But always like showing it off in as many places as I can. :D", "updateAuthor": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-06T18:44:13.000+0000", "updated": "2018-02-06T18:44:13.000+0000" }, { "id": "434558", "author": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "body": "[~hknoechel] will we be able to keep doing the following in the next version of titanium. or will this no longer be an option with the changes to jscore?\r\n\r\n{code:xml}\r\n\r\nfalse\r\n\r\nfalse\r\n{code}\r\n\r\n", "updateAuthor": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "created": "2018-02-16T06:07:57.000+0000", "updated": "2018-02-16T06:07:57.000+0000" }, { "id": "434577", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~threethirds] It will be removed in SDK 8.0.0 (~ 6-7 months). But we won't remove it before every related issue isn't fixed. So if you see any other issues, please report them! :-)\r\n\r\nThis one will be fixed in 7.2.0 and the PR is coming next week, but you guys can already use the patched library for now.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-02-16T20:09:09.000+0000", "updated": "2018-02-16T20:09:55.000+0000" }, { "id": "434619", "author": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "body": "hi [~hknoechel] \r\n\r\nwith 8.0.0 can we still do run-on-main-thread==false?\r\neven if we use jscore true.\r\n\r\nOr will run-on-main-thread also be a requirement?\r\n\r\nThanks,\r\nAnthony\r\n\r\n", "updateAuthor": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "created": "2018-02-18T23:40:15.000+0000", "updated": "2018-02-18T23:40:15.000+0000" }, { "id": "435253", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~threethirds] It is planned to only use those two and remove the deprecated legacy API's. That's why it's very important to get feedback now, so any possible issues can be addressed.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-06T19:34:40.000+0000", "updated": "2018-03-06T19:34:40.000+0000" }, { "id": "435371", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR (APSHTTPClient) : https://github.com/appcelerator/APSHTTPClient/pull/43", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-03-08T04:00:37.000+0000", "updated": "2018-03-08T04:00:37.000+0000" }, { "id": "437358", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~hknoechel] Please create PR for titanium sdk using updated library of APSHTTPClient. Thanks!", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-05-04T03:04:28.000+0000", "updated": "2018-05-04T03:04:28.000+0000" }, { "id": "437382", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR (titanium_mobile/master): https://github.com/appcelerator/titanium_mobile/pull/10027", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-05-04T15:53:18.000+0000", "updated": "2018-05-04T15:53:18.000+0000" }, { "id": "438212", "author": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I'm back on this, I missed most of these responses some how. But I have to tell you this is not fixed I'm testing with the current build os 7.3.0 and while better then it was before its not even close to how it is with jscore-framework set to false. Its still very easy to get 400MB + ram usage with a few uploads. In my app I am doing 8, 10MB uploads and I can get 400MB+ ram usage with out it really clearly with this fix. But if I use jscore-framework set to false it performs much better and clears the upload ram after each time. \r\n\r\nI'm not quite sure how to make a test app to recreate this or what info to give you to show the issue. But in the app that is doing 8 uploads after running it 4 times I currently have 486MB of ram used. On a 7 Plus iPhone thats not an issue but the smaller or older phones with 2GB or 1GB of ram this is a problem. Deprecating jscore-framework would be an issue as it is right now. ", "updateAuthor": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-07T14:34:58.000+0000", "updated": "2018-06-07T14:34:58.000+0000" }, { "id": "439341", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~dlewis23] Sorry for the late response. We have tested this internally a few times and did not see any issues. While some portion of the data stays in RAM for bit, the remaining portion gets GC'd after a few seconds, so it should not crash in any case anymore. This is because prior to the native JSCore, we manually flushed the GC every few seconds, which was noticeable via Instruments but also was a huge performance hit in other places. We are planning to go with this fix in 7.3.0 and are in the progress of more fine-tuning before SDK 8 arrives.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-07-19T12:09:16.000+0000", "updated": "2018-07-19T12:09:16.000+0000" }, { "id": "440658", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing as we are unable to reproduce the issue using SDK 7.3.0.v20180809095942", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2018-08-10T20:55:55.000+0000", "updated": "2018-08-10T20:55:55.000+0000" } ], "maxResults": 17, "total": 17, "startAt": 0 } } }