Add periodic time observer to playing AVPlayer, EXC_BAD_ACCESS in serial dispatch queue

Originator:erikprice
Number:rdar://14864491 Date Originated:28-Aug-2013 11:25 PM
Status:Open Resolved:
Product: Product Version:
Classification: Reproducible:Yes
 
28-Aug-2013 11:25 PM Erik Price:
Summary:
Adding a periodic time observer to an AVPlayer playing an HLS asset using a serial dispatch queue results in a crash in -[AVPlayerPeriodicCaller _effectiveRateChange] .

Steps to Reproduce:
1. Create an AVPlayer for a HLS URL and add its AVPlayerLayer to the view hierarchy.
2. Call -play on the AVPlayer.
3. Create a dispatch_queue_t using dispatch_queue_create("myQueue", DISPATCH_QUEUE_SERIAL).
4. Add a periodic time observer to the AVPlayer on the created dispatch queue using an interval of CMTimeMake(120.0f, 600) and an empty block (or just put a call to NSLog in the block).

Expected Results:
I expected the periodic time observer to execute the block with no problems.

Actual Results:
Nearly every time I can get this to EXC_BAD_ACCESS in -[AVPlayerPeriodicCaller _effectiveRateChange]. If I can't, then I just have to add another periodic observer or two and it will crash reliably.

Regression:

Notes:
I'm attaching a zipped Xcode project that demonstrates the bug. Run the app in the iOS simulator and then click the "BOOM" button to add the periodic time observer(s).

28-Aug-2013 11:25 PM Erik Price:
'AVPlayerPeriodicCallerCrash.zip' was successfully uploaded

29-Aug-2013 11:17 AM Erik Price:
I do not experience the crash if I insert a call to -pause immediately before adding the periodic observer and then insert a call to -play immediately afterward. This is a sufficient workaround for my needs, but it should be documented that periodic observers should not be added to an already-playing AVPlayer when using private serial dispatch queues.

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!