AVCaptureSession preview is broken on iOS 14

Number:rdar://FB8785505 Date Originated:Oct 8, 2020
Status:Open Resolved:
Product:AVFoundation Product Version:
Classification: Reproducible:
I have an app that uses AVCaptureSession to show preview from camera and capture photos. AVCaptureVideoPreviewLayer is used for preview.
The issue I’m seeing happens on iOS 14 only, and only on iPhone 11 Pro. Not reproducible on XS. Happens both if built with Xcode 11.6 or 12.

Sometimes, device enters such state that preview from camera are black. 
If I log preview layers state when this occurs, it has following state:
layer.isPreviewing - false
layer.session.isRunning - true
layer.session.isInterrupted - false
layer.connection.isEnabled - true
layer.connection.isActive - true

This affects all apps that use similar stack at once. The season is running and preview is black. Sometimes taking a photo fixes it and previews start coming through.

This happens on Apples own AVCam example project too, if one small setting is changed.

Changing photoOutput.isLivePhotoCaptureEnabled to false makes the AVCam app become affected too. 
Any session with such output gets black preview. Another session with photo output with isLivePhotoCaptureEnabled true is not affected and shows preview as expected.

Many other apps are affected as well, for example Vivino. They observe isPreviewing property on the layer, which never becomes true, so they show placeholder forever.

It’s not always that device is in such state. Sometimes everything is as normal and previews show up as expected.
But sometimes, the previews don’t work for hours straight, and even restarting the phone does not help. 

We got customer reports that they cannot use camera in our app after updating to iOS 14. But next day they could use it again. On our own testing, I got the preview blackness on few days for many hours in a row (I was able to investigate and find out that setting isLivePhotoCaptureEnabled to yes “fixes” it). But some days I was not able to get the issue again.

In sysdiagnose, last it happened was October 6 around 8-9 am gmt.

Attaching example project which is the same as AVCam sample with one line change.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!