CameraEngine icon indicating copy to clipboard operation
CameraEngine copied to clipboard

AVCapturePhotoSettings

Open basuru13 opened this issue 9 years ago • 2 comments

When taking a sequence of photos with the camera example, I get the following error:

-[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] Settings may not be re-used'

Any idea how to create a unique value for the settings?

basuru13 avatar Oct 02 '16 23:10 basuru13

let me check that in detail. Thanks for reporting this issue.

remirobert avatar Oct 03 '16 07:10 remirobert

I've run into a similar problem when taking more than one photo in my app. I traced the issue back to the reuse of the self.capturePhotoSettings object that has the same uniqueId.

Here is the Apple Doc reference: https://developer.apple.com/reference/avfoundation/avcapturephotosettings

Important

It is illegal to reuse a AVCapturePhotoSettings instance for multiple captures. Calling the capturePhoto(with:delegate:) method throws an exception (invalidArgumentException) if the settings object’s uniqueID value matches that of any previously used settings object.

To reuse a specific combination of settings, use the init(from:) initializer to create a new, unique AVCapturePhotoSettings instance from an existing photo settings object.

My workaround was to modify the source code as follows.

CameraEngine.swift - line 461

public func capturePhoto(_ blockCompletion: @escaping blockCompletionCapturePhoto) {
        let uniqueSettings = AVCapturePhotoSettings.init(from: self.capturePhotoSettings)
        self.cameraOutput.capturePhoto(settings: uniqueSettings, blockCompletion)
    }

This seems to be working for me now. I hope this is helpful to you guys.

natewitty avatar Oct 22 '16 23:10 natewitty