AVCaptureSession and GrabThreadHandler error

I have an application where I use AVCaptureSession along with AVCaptureScreenInput to capture my monitors. Everything works as expected most of the time but sometimes there is a delay on getting the frames, it varies how long it takes but when that happens I see this error in the console.

 CMIO_Unit_Input_ASC.mm:3442:GrabThreadHandler Error: signalling end of data because the CG grab failed for 10 seconds, which usually means the display went to sleep

I looked around and I wasn't able to find anything on that particular error, not I have been able to reproduce it or notice anything specific that could be causing it.

NOTE: I'm currently implementing it using ScreenCaptureKit but in the mean time I need to try and fix this.

AVCaptureSession and GrabThreadHandler error
 
 
Q