Skip to content

[camera_avfoundation] Errors during video recording causes inaccessible recording files to be saved to NSDocumentDirectory #166933

Description

@misos1
  1. It pretends like a file is created in some temporary directory (where files will be deleted at some point) by using a function with name getTemporaryFilePathWithExtension. But that function actually uses NSDocumentDirectory and the path can look like "/var/mobile/Containers/Data/Application/{some_id}/Documents/camera/videos" which looks like a persistent directory specific for the app. So it is a good idea to delete generated videos on the dart side at some point (maybe good to at least document this?), otherwise it will eventually fill the entire storage and one would need to delete and reinstall the app. Problem is that the recorded file is obtained by calling stopVideoRecordingWithCompletion and if some error happens before this or during a call to it then it is not possible to obtain that file on the dart side. Currently a workaround could be to use some plugin like path_provider and use hard coded path generation in a similar way as camera_avfoundation does (for example to clear that folder in case of error), which is prone to problems if something changes. Maybe camera_avfoundation should really rather use some temporary folder or prevent these leaks by some other means.

  2. Also when stopVideoRecordingWithCompletion fails it updates internal state in camera_avfoundation about recording to false but on the dart side in camera this is not updated. So trying to record something in this state will throw "Unhandled Exception: CameraException(A video recording is already started., startVideoRecording was called when a recording is already started.)" and on the other hand trying to stop recording throws "CameraException(Error -1008, Video is not recording!)".

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.perf: memoryPerformance issues related to memoryplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions