AVCaptureOutput didOutputSampleBuffer stops getting called

限于喜欢 提交于 2019-12-04 08:39:42

Your problem is actually referenced in the Docs, Specifically;

If your application is causing samples to be dropped by retaining the provided CMSampleBufferRef objects for too long, but it needs access to the sample data for a long period of time, consider copying the data into a new buffer and then releasing the sample buffer (if it was previously retained) so that the memory it references can be reused.

Essentially, you need to keep the callback operation as simple as possible, and should you need to perform further processing on the frame passed to you in the callback, you need to copy it to a new buffer and perform the processing in the background. Also, Keep in mind that Core Foundation object must explicitly be retained and released.

A further consideration is memory pressure. Frames contain lots of data, retaining too many will cause your app to crash.

I encounter similar issue in Xamarin(C#) iOS development. Use the following code to release the CMSampleBuffer if in Xamarin:

GC.Collect();
GC.WaitForPendingFinalizers();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!