Issue
After an Update to 12.4 my AVCapture session is using between 70-90% CPU
That code is just a simple capture session in a Mac Catalyst App with the webcam of the Mac. The session calls an empty func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)
and nothing more is happing in the test app I tried. Also no rendering of the stream.
My test code ran with 10-15% CPU usage a week ago, before I made an update today to macOS 12.4 - with rendering into a Metal view maybe 20-25%
To reproduce:
- take AVCam project https://developer.apple.com/documentation/avfoundation/capture_setup/avcam_building_a_camera_app
- Set checkbox for Mac Catalyst Support in General
- run on Mac
The original sample code from Apple is also running with the same high CPU usage. But even my AVCaptureSession code ran a week ago at about 15% which might even be too much.
I have tested this on a 2019 Intel MacBook pro and also tried it on a macOS 12.4 iMac which did result in the same high CPU usage with all the test apps.
Update to macOS 12.5 Beta 3 did also not help. But I know it ran better with macOS <12.4 and also almost 100% CPU even with 800% overall available is too much for just camera capture
Profiling in Instruments
Insturments is showing me with the heaviest stack trace a lot VN calls with object detection - is this the camera autofocusing? Do I need to put more options for the capture device? I don't call anything from the Vision Framework - is this happening automatically?
It looks like this, feels like a lot of work for just the Mac webcam:
what to do?
Is this a problem with macOS 12.4? Do you have a better running Capture session on 12.4 and what is needed to archive that? Could this be a Catalyst problem? Is this a bug which needs a bug report with Apple? I can't really go back to a previous version, and it would be neat if the code would also work on macOS 12.4 haha