Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20439] Android: Using camera bloats app storage

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-11-14T21:38:50.000+0000
Affected Version/sRelease 5.2.0, Release 5.1.2
Fix Version/sRelease 7.0.0
ComponentsAndroid
Labelsandroid
ReporterSharif AbuDarda
AssigneeGary Mathews
Created2016-02-22T15:12:09.000+0000
Updated2017-11-15T05:42:37.000+0000

Description

During our testing we have realized that continuously taking camera images bloats app size. There is currently no way for us to check what is being stored. 1) Problem Description - taking a bunch of pictures (without saving them) bloats up app internal storage size. 2) Exact steps to reproduce: Download the app [here](https://c.na10.content.force.com/servlet/servlet.FileDownload?file=00PF000000WBSKA). - install supplied test app - in application manager: note the size of the app and storage space used - load supplied app - press "Open Camera Pictures" - press "Take" - press "Retake" - repeat 10 times - kill the app - go back to application manager and note size difference 3) Expected Behavior - no data to be saved. (Image saving is turned off by default according to docs) 4) Number of users affected - all Android users

Comments

  1. Sharif AbuDarda 2016-02-22

    Salesforce ticket 1[00008173](https://na10.salesforce.com/500F000000oUfKq). Salesforce ticket 2[00008174](https://na10.salesforce.com/500F000000oUfts).
  2. Sharif AbuDarda 2016-03-08

    Hello, If saveToPhotoGallery is set to false, taking image will increase the app size. *Steps to Reproduce* saveToPhotoGallery property must be set to false
       var showCamera = function() {
       	
       		Ti.Media.showCamera({
       			success:function(event) {
                                      alert('success');
       				
       			},
       			cancel:function() {			
       				// called when user cancels taking a picture
       			},
       			error:function(error) {
       				alert('error');
       			},
       			saveToPhotoGallery:false,
       		    // allowEditing and mediaTypes are iOS-only settings
       		});
       	};
       
       showCamera();
       
       
    Actual Result Every photo taken by camera (no matter if later saved or not) will take some space (data on device). There is no way to release that space or get that file, so it will continuously increase taken space until no space is left. If you save the image after taking it, than the space taken is doubled (you create additional file). Of course you can delete saved image but it will only release half of taken space. There is no problem if saveToPhotoGallery is set to true Expected Result Space taken by the image should be released or there should be the way to get the files taking that space.
  3. Hieu Pham 2016-03-08

    On Android, if saveToPhotoGallery is false, we store the image in internal storage and return it via success callback. If you wish to NOT use the image that is returned, you can delete it by doing something like this:
       success:function(event) {
                                       alert('success');
       				var blob = event.media;
       				var file = blob.getFile();
       				file.deleteFile();
       }
       
    This is likely the same for iOS.
  4. Nazmus Salahin 2016-03-09

    I am able to reproduce this issue with the given project and given steps. Initially the application manager showed that the app used 23.7 MB internal storage but after following the given steps it becomes 39.4 MB. But if I change the "openCamera()" function in the project as follows: [Gist Link](https://gist.github.com/N-Salahin/05c9819b41005bb73cd1) then the issue is solved. The app size remains 23.7 MB even after following the steps now. *Environment*: *Device info:* Nexux7 (android 6.0.1) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDKs:* 5.2.0 and 5.1.2.GA *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5
  5. Collin Price 2016-03-21

    If I don't use *deleteFile* when is the file flushed from internal storage?
  6. Sharif AbuDarda 2016-03-31

    Hello, It depends on the internal storage, The operation will just increase the app size. And you can clean the data manually from the app. I think the best resolution for an user is to put the delete function in the app and automatically delete a file when not saved. Cause the user might not always clean the cache. So, from a developer perspective using the automatically delete option should be best practice. Regards, Sharif
  7. Nikita Radaev 2016-03-31

    I disagree. This IS a bug. In my opinion it should be fixed instead of using workarounds. This functionality should be an option of Ti.Media.ShowCamera in CameraOptionsType. Otherwise, you rely on developers using workaround that is not documented anywhere.
  8. Nikita Radaev 2017-03-24

    How is this being marked as resolved? Nothing has been done to resolve this issue....
  9. Gary Mathews 2017-08-28

    master: https://github.com/appcelerator/titanium_mobile/pull/9362
  10. Lokesh Choudhary 2017-11-13

    FR Passed. Waiting for merge to get enabled.
  11. Lokesh Choudhary 2017-11-14

    PR Merged.
  12. Abir Mukherjee 2017-11-15

    Changes are seen in SDK 7.0.0.v20171114202841.

JSON Source