Get camera list on MacOS stuck UI with camera entitlements

Create a new mac os app in Xcode 14.

Fetch camera list by these code:

NSArray *devicesIOS = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];

then change the architecture to x86_64

snd add com.apple.security.device.camera to entitlements

then this code will cost 4s and UI will be stuck during next half minutes on M1 machine running MacOS 13

This causes a lot of apps stuck at starting like Zoom and Classin

How to solve this?

This only happens on M1 machine with MacOS ventura

Im also facing this problem too. only x86_64 app running on rosetta.

We also faced the issue, any update recently ?

devicesWithMediaType is deprecated.

Use AVCaptureDeviceDiscoverySession:

let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera],
                                                        mediaType: .video,
                                                        position: .unspecified)
let devices = discoverySession.devices

and do it in a separate thread, it will take a second or two, not more.

Get camera list on MacOS stuck UI with camera entitlements
 
 
Q