I have an application which work correctly with previous iOS versions, but then I tried run it on device with iOS7, application crashed sporadic. I tried to make a build with Xcode 5 which was recommended by Apple iOS7 GM SDK for upgrade existing apps, but the problem wasn't solved. I tried to research Apple documentation for AVCaptureSession
, but also didn't found anything
my code is simple and standard
-(void)addVideoInput {
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (videoDevice) {
NSError *error;
self.videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
if ([self.captureSession canAddInput:self.videoInput]) {
[self.captureSession addInput:self.videoInput];
}
}
}
the app crashed in my function with next Stacktrace:
0 libobjc.A.dylib 0x395adb26 objc_msgSend + 5
1 AVFoundation 0x2e33a991 <redacted> + 348
2 AVFoundation 0x2e33aca1 <redacted> + 112
3 AVFoundation 0x2e33c4d1 <redacted> + 316
4 AVFoundation 0x2e33560f <redacted> + 354
5 AVFoundation 0x2e339bf1 <redacted> + 1436
6 Foundation 0x2fdbed31 <redacted> + 272
7 Foundation 0x2fdbe9d5 <redacted> + 344
8 Foundation 0x2fdaafed <redacted> + 88
9 AVFoundation 0x2e327483 <redacted> + 94
10 AVFoundation 0x2e33c505 <redacted> + 368
11 AVFoundation 0x2e3362c7 <redacted> + 906
12 myApp 0x00156159 -[CaptureManagerUniversal addVideoInput] + 540
13 myApp 0x00154cdf -[CaptureManagerUniversal init] + 2178
14 myApp 0x00077575 -[ViewFinderViewController didAppearActions] + 312
15 myApp 0x00077b11 -[ViewFinderViewController viewDidAppear:] + 128
16 UIKit 0x3199d43b <redacted> + 410
17 UIKit 0x3199d8bd <redacted> + 264
18 UIKit 0x31a4a4cb <redacted> + 870
19 UIKit 0x31a4a15b <redacted> + 274
20 UIKit 0x319bb417 <redacted> + 178
21 UIKit 0x319bb32f <redacted> + 70
22 QuartzCore 0x31613d99 <redacted> + 232
23 libdispatch.dylib 0x39ab1d67 <redacted> + 22
24 libdispatch.dylib 0x39ab87c1 <redacted> + 268
25 CoreFoundation 0x2f47a811 <redacted> + 8
26 CoreFoundation 0x2f4790e5 <redacted> + 1300
27 CoreFoundation 0x2f3e3cd7 CFRunLoopRunSpecific + 522
28 CoreFoundation 0x2f3e3abb CFRunLoopRunInMode + 106
29 GraphicsServices 0x33e602db GSEventRunModal + 138
30 UIKit 0x319e8121 UIApplicationMain + 1136
31 myApp 0x00097a9d main + 11 6
I added to dealloc
method in my custom CaptureManager:
[self.captureSession removeInput:self.videoInput];
[self.captureSession removeOutput:self.videoOutput];
before
self.captureSession = nil;
self.videoOutput = nil;
self.videoInput = nil;
and it is working for me (for iOS7 as well)
my dealloc
method now is:
- (void)dealloc {
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter removeObserver:[self deviceConnectedObserver]];
[notificationCenter removeObserver:[self deviceDisconnectedObserver]];
[notificationCenter removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[self.captureSession stopRunning];
[self.captureSession removeInput:self.videoInput];
[self.captureSession removeOutput:self.videoOutput];
self.captureSession = nil;
self.videoOutput = nil;
self.videoInput = nil;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With