Why deleteRecording crashed (AVAudioRecorder, iOS)?

2

[recorder deleteRecording]; works well 30 times, but around 31 it crashes.

0   libobjc.A.dylib                 0x3266fc98 objc_msgSend + 16
1   Foundation                      0x328c203c -[NSError dealloc] + 36
2   CoreFoundation                  0x30d2dc3c -[NSObject(NSObject) release] + 24
3   Foundation                      0x328e687c -[NSFilesystemItemRemoveOperation dealloc] + 36
4   Foundation                      0x328bc7b2 -[NSOperation release] + 38
5   CoreFoundation                  0x30d2e19a CFRelease + 62
6   CoreFoundation                  0x30d30eb4 _CFAutoreleasePoolPop + 140
7   Foundation                      0x328abbae NSPopAutoreleasePool + 2
8   Foundation                      0x3293a908 __NSThreadPerformPerform + 620
9   CoreFoundation                  0x30da0a72 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
10  CoreFoundation                  0x30da2758 __CFRunLoopDoSources0 + 376
11  CoreFoundation                  0x30da34e4 __CFRunLoopRun + 224
12  CoreFoundation                  0x30d33ebc CFRunLoopRunSpecific + 224
13  CoreFoundation                  0x30d33dc4 CFRunLoopRunInMode + 52
14  GraphicsServices                0x31896418 GSEventRunModal + 108
15  GraphicsServices                0x318964c4 GSEventRun + 56
16  UIKit                           0x355b9d62 -[UIApplication _run] + 398
17  UIKit                           0x355b7800 UIApplicationMain + 664
18  AppName                         0x000020f6 main (main.m:16)
19  AppName                         0x00002050 start + 44
iphone
ipad
crash
avaudiorecorder
asked on Stack Overflow Dec 13, 2011 by Geri Borbás

1 Answer

3

I found that this happens when deleteRecording is trying to delete a non existent file. So check if file exists before you call it:

if ([[NSFileManager defaultManager] fileExistsAtPath:self.recorder.url.path]) {
        if (![self.recorder deleteRecording])
            NSLog(@"Failed to delete %@", self.recorder.url);
}

It must be a bug in AVAudioRecorder.

answered on Stack Overflow Sep 27, 2013 by Lemme

User contributions licensed under CC BY-SA 3.0