Skip to content

AVCaptureDevice requestAccessForMediaType should explicitly call [self setup] on main thread #17

@ExoticObjects

Description

@ExoticObjects

I was getting black screen failures when running SimpleCam on a device for the first time.

Apple's documentation for AVCaptureDevice requestAccessForMediaType says: "The completion handler is called on an arbitrary dispatch queue. Is it the client's responsibility to ensure that any UIKit-related updates are called on the main queue or main thread as a result."

Once I put this kind of stuff in:

dispatch_async(dispatch_get_main_queue(), ^{
    [self setup];
    [self animateIntoView];
});

the issue went away.

Note that it's easy to miss this, as, AFAICT, camera access is granted for the entire device even though the popup asks permission for the app. So once you've authorized the camera at all on a development device, SimpleCam's auth routines will work. But it not, not... To debug this, I ended up changing the bundle id, as this guy suggests.

Unfortunately I can't submit a pull request, as we've too heavily modified your code to work with a specific project. But hopefully this should help. SimpleCam is great. Thanks!

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions