{ "id": "162246", "key": "TIMOB-23699", "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": "16980", "description": "New V8", "name": "Release 6.0.0", "archived": false, "released": true, "releaseDate": "2016-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-08-01T07:22:18.000+0000", "created": "2016-07-28T20:22:39.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "camera" ], "versions": [ { "id": "17972", "name": "Release 5.3.1", "archived": false, "released": true, "releaseDate": "2017-02-06" } ], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2016-10-07T17:27:02.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": "h6. Issue Description \r\n\r\nVideo is recorded and saved to the \"Photos\" app successfully, but it apparently is also saved in the \"applicationDataDirectory\". Looking at the physical iPhone > Settings > Usage > Storage, the size of the app increase the exact same amount of the video that was just recorded. After capture more videos, the app is bigger.\r\n\r\nh6. Steps to reproduce\r\n# Create a new classic app project\r\n# Replace the code inside app.js to the next one\r\n{code}\r\n//Camera Issue with temp storage case#00010479\r\nvar win = Titanium.UI.createWindow({\r\n title:\"Using the Camera and Video\",\r\n backgroundColor:\"#FFFFFF\"\r\n});\r\n\r\nvar button = Titanium.UI.createButton({\r\n title:\"Use camera\",\r\n width:180,\r\n height:48,\r\n bottom: 12,\r\n zIndex:2\r\n});\r\n\r\nbutton.addEventListener(\"click\", function(e){\r\n //Open the photo gallery\r\n Titanium.Media.showCamera({\r\n //function to call upon successful load of the gallery\r\n success:function(e){\r\n if(e.mediaType === Titanium.Media.MEDIA_TYPE_PHOTO){\r\n //e.media represents the photo or video\r\n var imageView = Titanium.UI.createImageView({\r\n image:e.media,\r\n width:320,\r\n height:480,\r\n top:12,\r\n zIndex:1\r\n });\r\n win.add(imageView);\r\n }else if(e.mediaType === Titanium.Media.MEDIA_TYPE_VIDEO){\r\n\r\n var w = Titanium.UI.createWindow({\r\n title:\"New Video\",\r\n backgroundColor:\"#000000\"\r\n });\r\n\r\n var videoPlayer = Titanium.Media.createVideoPlayer({\r\n media:e.media,\r\n backgroundColor:\"#FFFFFF\",\r\n \r\n });\r\n\r\n w.add(videoPlayer);\r\n\r\n videoPlayer.addEventListener(\"complete\", function(e){\r\n w.remove(videoPlayer);\r\n videoPlayer = null;\r\n w.close();\r\n });\r\n\r\n w.open({modal:true});\r\n }\r\n\r\n },\r\n error:function(e){\r\n alert(\"There was an error\");\r\n },\r\n cancel:function(e){\r\n alert(\"The event was cancelled\");\r\n },\r\n //Allow editing of media before success\r\n allowEditing:true,\r\n saveToPhotoGallery:true,\r\n //Media types to allow\r\n mediaTypes:[Titanium.Media.MEDIA_TYPE_PHOTO,Titanium.Media.MEDIA_TYPE_VIDEO],\r\n //The other is Titanium.Media.MEDIA_TYPE_VIDEO,\r\n //If recording video, you can set the quality to record at\r\n videoQuality:Titanium.Media.QUALITY_HIGH\r\n /*other possible values for this property are\r\n * Titanium.Media.QUALITY_MEDIUM\r\n * Titanium.Media.QUALITY_LOW\r\n */\r\n });\r\n});\r\n\r\nTitanium.App.addEventListener('camera_button', function(){\r\n Titanium.Media.takePicture();\r\n});\r\n\r\nwin.add(button);\r\n\r\nwin.open();\r\n\r\n{code}\r\n# Run\r\n# Record a video\r\n# Check the app size\r\n\r\nh6. Expected results \r\nApp should flush the videos if they are not longer used after the app is killed", "attachment": [], "flagged": false, "summary": "iOS Media.showCamera \"Temp\" file issue", "creator": { "name": "rramirez", "key": "rramirez", "displayName": " Ricardo Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "rramirez", "key": "rramirez", "displayName": " Ricardo Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "iOS 9.3 \r\nXcode 7.2\r\nAppcelerator SDK 5.3.1", "closedSprints": [ { "id": 685, "state": "closed", "name": "2016 Sprint 16 SDK", "startDate": "2016-07-30T00:40:02.939Z", "endDate": "2016-08-13T00:40:00.000Z", "completeDate": "2016-08-15T08:00:33.056Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "392088", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "It is not stored in the documents directory by default. The file is stored in /tmp where it gets flushed by iOS as soon as the terminates and/or space gets low. See [this screen|https://abload.de/img/bildschirmfoto2016-08ldxnl.png] for details.\r\n\r\nAnyway, we have the following snippet in the code, if the user manually edits the video (by dragging the start end end of the video that saves the file [here|https://abload.de/img/bildschirmfoto2016-085rzc9.png] indeed:\r\n{code:objc}\r\nNSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);\r\nNSString *documentsDirectory = [paths objectAtIndex:0];\r\n{code}\r\n\r\nSo that may needs to be replaced with\r\n{code:objc}\r\nNSString *tmpDirectory = [[NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES] path];\r\n{code}", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-08-01T05:30:30.000+0000", "updated": "2016-08-01T05:33:09.000+0000" }, { "id": "392089", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/8180\r\n\r\nDemo (simplified test-case):\r\n{code:javascript}\r\nvar win = Titanium.UI.createWindow({\r\n backgroundColor: \"#FFFFFF\"\r\n});\r\n\r\nvar button = Titanium.UI.createButton({\r\n title: \"Open camera\"\r\n});\r\n\r\nbutton.addEventListener(\"click\", function(e) {\r\n if (!Ti.Media.hasCameraPermissions()) {\r\n Ti.Media.requestCameraPermissions(takeVideo);\r\n } else {\r\n takeVideo();\r\n }\r\n});\r\n\r\nwin.add(button);\r\nwin.open();\r\n\r\nfunction takeVideo() {\r\n Ti.Media.showCamera({\r\n success: function(e) {\r\n Ti.API.info(\"Video captured successfully!\");\r\n },\r\n error: function(e) {\r\n alert(\"There was an error\");\r\n },\r\n cancel: function(e) {\r\n alert(\"The event was cancelled\");\r\n },\r\n allowEditing: true,\r\n saveToPhotoGallery: true,\r\n mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO],\r\n videoQuality: Ti.Media.QUALITY_HIGH\r\n });\r\n}\r\n{code}\r\n\r\nImportant: On iOS 10 and later, we need to store the following keys in the Info.plist in order to access the sensors:\r\n{code:xml}\r\n\tNSCameraUsageDescription\r\n\tCan we use your camera?\r\n\tNSMicrophoneUsageDescription\r\n\tCan we use your microphone?\r\n\tNSPhotoLibraryUsageDescription\r\n\tCan we save to your library?\r\n{code}\r\n\r\nI already updated the docs for this iOS 10 change, but I may do additional logs to ensure that the user knows about this change. ", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-08-01T05:44:03.000+0000", "updated": "2016-08-01T05:44:03.000+0000" }, { "id": "392094", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "PR merged.", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-08-01T07:22:07.000+0000", "updated": "2016-08-01T07:22:07.000+0000" }, { "id": "396870", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Verified fixed, using:\r\nMacOS 10.12 (16A323)\r\nStudio 4.7.1.201609100950\r\nTi SDK 6.0.0.v20160921004951\r\nAppc NPM 4.2.7\r\nAppc CLI 6.0.0-7\r\nAlloy 1.9.1\r\nXcode 8.0 (8A218a)\r\n\r\nRecorded videos are saved in the {{tmp}} folder of the app container, even after editing. Tested using the provided sample code as well as other test apps that use the camera. Uncovered TIMOB-23937 during testing (edited videos are not saved to photo gallery), but this issue is resolved.", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-09-21T20:50:50.000+0000", "updated": "2016-09-21T20:50:50.000+0000" }, { "id": "398342", "author": { "name": "amwinsauto", "key": "amwinsauto", "displayName": "Adam Armstrong", "active": true, "timeZone": "America/Chicago" }, "body": "*Hans pointed me to the changes made to iphone/Classes/MediaModule.m*\r\n(at this link https://github.com/appcelerator/titanium_mobile/pull/8180/files)\r\n\r\n*I Removed the 3 lines and added the 2 lines as defined in the URL.*\r\n - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);\r\n - NSString *documentsDirectory = [paths objectAtIndex:0];\r\n + NSString *tmpDirectory = [[NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES] path];\r\n \r\n - NSString *outputURL = [documentsDirectory stringByAppendingPathComponent:@\"editedVideo\"];\r\n + NSString *outputURL = [tmpDirectory stringByAppendingPathComponent:@\"editedVideo\"];\r\n\r\nDeleted App from my phone.\r\nCleaned Build / Deleted \"build\" folder\r\nPackaged app to my phone\r\nChecked Settings > Storage to see my app was 21 mb\r\nTook video inside app\r\nClosed/Killed app\r\nChecked Settings again - app size increased to 29.9 mb\r\nSent video to my Macbook and checked file size in Mac OS....8.9 mb\r\nThe video is still taking up space inside the App Storage and not being removed after killing the app.\r\n\r\nAdam", "updateAuthor": { "name": "amwinsauto", "key": "amwinsauto", "displayName": "Adam Armstrong", "active": true, "timeZone": "America/Chicago" }, "created": "2016-10-07T13:56:58.000+0000", "updated": "2016-10-07T13:56:58.000+0000" }, { "id": "398343", "author": { "name": "amwinsauto", "key": "amwinsauto", "displayName": "Adam Armstrong", "active": true, "timeZone": "America/Chicago" }, "body": "- Also worth noting. \r\n\r\nThis ticket was originally created referencing the use case of just simply recording a video - no mention of editing. Somewhere along the way and troubleshooting this issue, someone else added the context of \"edit video\". But I never defined that as the original issue. Looking over the PR changes that were applied (specifically referencing \"editedVideo\") I'm concerned that the original issue may not have been addressed - just a simple video recording. Especially given my results after applying the suggested changes.\r\n\r\nAdam.", "updateAuthor": { "name": "amwinsauto", "key": "amwinsauto", "displayName": "Adam Armstrong", "active": true, "timeZone": "America/Chicago" }, "created": "2016-10-07T14:11:01.000+0000", "updated": "2016-10-07T14:11:01.000+0000" }, { "id": "398368", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "[~amwinsauto] I checked this again and found the same results that I posted before. I believe the main issue here was that files were not being saved to the correct place and/or they were not being removed at the seemingly appropriate time. As Hans indicated and as testing has supported, videos are correctly being saved to the {{tmp}} folder (and after the PR, edited videos are saved there as well). The app itself is responsible for removing these files, however Apple can remove them at any time that the app is not running. This is not necessarily on app close. Apple docs snippet for references:\r\n{quote}\r\nPut temporary data in the tmp/ directory. Temporary data comprises any data that you do not need to persist for an extended period of time. Remember to delete those files when you are done with them so that they do not continue to consume space on the user’s device. The system will periodically purge these files when your app is not running; therefore, you cannot rely on these files persisting after your app terminates.\r\n{quote}\r\n\r\nThat being said, if you do ever encounter a file not being saved to the {{tmp}} folder, please let us know.", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-10-07T17:27:02.000+0000", "updated": "2016-10-07T17:27:02.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }