AVCaptureVideoPreviewLayer layoutSublayers invoked on background thread

Opening this question after discussing the issue in the AVCapture lab, hopefully so we can track down this issue.

We've been noticing some crashes in App Store Connect caused by layoutSublayers being called on a background thread.

After debugging the issue a bit we found that all calls which modified the AVCaptureSession or preview layer were indeed done on the main thread. It would be useful to see what results in AVCaptureVideoPreviewLayer.updateFormatDescription being called.

I've attached the crashlog below.





AVCaptureVideoPreviewLayer layoutSublayers invoked on background thread
 
 
Q