EXC_BAD_ACCESS when stopping AVCaptureSession

Originator:jonas
Number:rdar://15514479 Date Originated:20-Nov-2013 06:00 PM
Status:Closed Resolved:Yes
Product:OS X Product Version:10.9
Classification: Reproducible:Yes
 
Summary:
After upgrading to Mavericks, calling stopRunning on a running AVCaptureSession frequently causes the running thread to crash with exception type:  EXC_BAD_ACCESS (SIGSEGV). 

It appears to happen more frequently when a session has been running for a longer period of time (10-15 mins)

Sample code Xcode project demonstrating the issue:
https://minbox.com/app/collections/dcMQjaa5PQ

Steps to Reproduce:
1. initiate AVCaptureSession.new
2. add AVCaptureScreenInput as video input
3. add AVCaptureDeviceInput for mic input
4. add AVCaptureMovieFileOutput for output
5. call startRunning on session
6. call startRecordingToOutputFileURL on output
7. wait x minutes
8. call stopRecording on output
9. call stopRunning on session from captureOutput:didFinishRecordingToOutputFileAtURL:fromConnections:error:

Expected Results:
The session should stop running asynchronously 

Actual Results:
Frequently, the thread crashes upon calling stopRunning on AVCaptureSession

Version:
 OS X 10.9 (13A603)

Notes:


Configuration:
Mavericks 10.9 on Macbook Pro (15-inch, Late 2008)

Comments

Resolved

Call stop on main thread instead of:

dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ … startRunning... });


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!