Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20367] Android: TiHTTPClient leaking files when response > 512K

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-05-17T07:10:38.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.3.0
ComponentsAndroid
Labelsandroid
Reportergrebulon
AssigneeGary Mathews
Created2016-02-04T11:51:14.000+0000
Updated2018-07-02T21:56:59.000+0000

Description

The problem begins in *TiHTTPClient.java*, handleEntityData(). If the response size > 512K (totalSize > maxBufferSize) it calls createFileResponseData(true) and a temporary data file is created (outFile = TiFileFactory.createDataFile("tihttp", "tmp")). This file is never deleted and remains in the appdata directory.

Comments

  1. Sharif AbuDarda 2016-02-08

    Hello, Can you provide a full test code and steps to reproduce the issue that you are having? We will try to regenerate the issue in out environment. Please be more descriptive as possible Also please provide the full environment info in where you are generating the issue. Thanks.
  2. grebulon 2016-02-08

    I don't know how to reproduce this, it happens occasionally. I can see the problem just by looking at the code.
  3. Rene Pot 2017-01-19

    Having the same issue. I've got my hands on a device that has been using my app since October. There was 100mb of http client responses in there. A couple every day (even though there are many more requests done by the user/app/phone). The line of code that is creating the files is here: https://github.com/appcelerator/titanium_mobile/blob/64534e425e303fdb17834a10faf98101da440d3e/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java#L283 I can (almost) confirm it happens > 512k. But there is 1 file that is 16kb on the device. All the others are bigger. I could imagine it having to do with the excludeFromCleanup line but I'm not familiar enough with the code to be able to conclude/confirm that https://github.com/appcelerator/titanium_mobile/blob/64534e425e303fdb17834a10faf98101da440d3e/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java#L271
  4. Sergey Volkov 2018-05-16

  5. grebulon 2018-05-16

    This ticket was opened over 2 years ago. They don't care. I'm deleting these files when the app first starts so they don't add up.
  6. Sergey Volkov 2018-05-16

    https://github.com/appcelerator/titanium_mobile/pull/10055
  7. Hans Knöchel 2018-05-17

    PR merged, thanks [~s.volkov]! The patch can be applied locally today if required.
  8. Samir Mohammed 2018-07-02

    *Closing ticket*. Fix verified in SDK Version 7.3.0.v20180628132121 *FR passed (Test Steps)*

    Created an application with the following code

       const win = Ti.UI.createWindow({ backgroundColor: 'gray' }),
           client = Ti.Network.createHTTPClient({
               onload: (e) => {
                   const isTemp = e.source.responseData.nativePath.includes('cache/_tmp') !== -1;
                   alert(path: ${e.source.responseData.nativePath}\n\nisTemp: ${isTemp});
               },
               onerror: (e) => {
                   Ti.API.error(e.error);
               },
               timeout: 3000
           });
       #R
       
       client.open('GET', 'https://www.nasa.gov/sites/default/files/thumbnails/image/sun_0.jpg');
       client.send();
       
       win.open();
       

    Ran the program

    Able to see HTTP responses save in "temp storage" instead of 'app-data://'.

    *Test environment*
       APPC Studio: 5.0.0.201712081732
       APPC CLI: 7.0.4
       Pixel XL (8.1.0)
       Operating System Name: Mac OS High Sierra
       Operating System Version: 10.13
       Node.js Version: 8.9.1
       Xcode 9.2
       

JSON Source