Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

AVCapturePhotoSettings #55

Open
basuru13 opened this issue Oct 2, 2016 · 2 comments
Open

AVCapturePhotoSettings #55

basuru13 opened this issue Oct 2, 2016 · 2 comments

Comments

@basuru13
Copy link

basuru13 commented Oct 2, 2016

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?

@remirobert
Copy link
Owner

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

@natewitty
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants