Debugging ReplayKit Broadcast samplebuffer extensions spawns hundreds of threads

Originator:joachimb
Number:rdar://28836045 Date Originated:18-Oct-2016 05:22 PM
Status:Open Resolved:
Product:iOS SDK Product Version:10.0
Classification:Other Bug Reproducible:Always
 
Summary:
When debugging a ReplayKit broadcast extension, every time I step in the debugger, another thread is spawned to deal with an incoming frame.

Steps to Reproduce:
1. Create a ReplayKit UI and broadcast extension
2. Configure the extension to use a sample handler
3. Launch the broadcast extension into an app, with the debugger active
4. Put a breakpoint in the - (void)processSampleBuffer:(CMSampleBufferRef)sampleBuffer withType:(RPSampleBufferType)sampleBufferType method
5. Step through that method line by line

Expected Results:
6. A single handler thread is used to process the callbacks into my code, dropping frames if the handler is too slow (e g when slowly stepping through the callback

Actual Results:
6. Each time I step, another thread is spawned to handle incoming frames, all pausing on my breakpoint and it becomes very difficult to follow along what’s actually happening


Notes:
Are you just dispatch_async’ing to a delegate queue for every frame? Won’t that completely saturate the CPU if the handler is every too slow in handling just a handfull of frames, spawning threads until a watchdog kills the process?

I learned a few weeks ago that dispatch_async is really bad for the producer-consumer pattern, as there’s no facility for push-back when the consumer is too slow (causing this exact issue in my own app, eventually watchdog-killing the app).

Comments


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!