15

It seems that finishWriting is broken on iOS 6 simulator - it hangs forever. It's now deprecated and replaced by the new finishWritingWithCompletionHandler: - which also never calls the handler.

On real devices running iOS 6, this works just fine as it always did. Also in previous iOS simulators it works just fine. Seems like a bug in iOS 6 simulator.

Anyone else experiencing this or can prove me wrong?

2 Answers 2

12

I had this issue as well, then realized that I wasn't calling endSessionAtSourceTime: after starting one. This resolved my issue.

2
  • 1
    This worked for me too. If you call finishWritingWithCompletionHandler: on your AVAssetWriter object then you do have to call endSessionAtSourceTime: before that in order for the completion handler to be invoked. (The documentations states that you don't have to call it if you use finishWriting, which has been deprecated since iOS 6.0.)
    – SolidSun
    Feb 7, 2013 at 17:56
  • Worked for me also. The deadlock didn't always happen, but the output file was never written correctly without the endSessionAtSourceTime: call. Oct 12, 2013 at 22:10
3

Ok found a work around on Simulator.

Looks like stop deadlocks the video processing thread so a workaround is to call stop in the main thread instead:

//      in iOS6 Simulator this blocks the video processing thread call back in UI thread.
//       BOOL stop = [assetWriter finishWriting];
[self performSelectorOnMainThread:@selector(stopInOtherThread) withObject:nil]; 

-(void)stopInOtherThread{
    //Stop doesn't block in MainThread
    BOOL stop = [assetWriter finishWriting];
    NSLog(@" assetWriter finishWriting :%d",stop);
}

This workaround doesn't seem to work for finishWritingWithCompletionHandler

I'll try and see if I can raise a bug on Apple.

3
  • I already posted a bug. The paradox is that since iOS6, if we call finishWriting on the main thread, the log shows: WARNING: -finishWriting should not be called on the main thread. Sep 22, 2012 at 16:42
  • I'm having the same problem. iOS6 simulator isn't called the handler, and status never changes off AVAssetWriterStatusWriting. Oct 6, 2012 at 17:36
  • 1
    I only started getting this after switching my project to use ARC.
    – Ray Fix
    Nov 11, 2012 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.