The crash report is here:
>Exception Type: SIGSEGV
>Exception Codes: SEGV_ACCERR at 0x16b
>Crashed Thread: 3
>Thread 3 Crashed:
>0 libobjc.A.dylib 0x0000000195e7bbc8 objc_msgSend + 8
>1 MSProject 0x00000001001888a4 -[MStateDataAnalysis stopRecogniseTask] (MStateDataAnalysis.m:85)
>.....
>7 libdispatch.dylib 0x00000001964e5954 _dispatch_client_callout + 16
>8 libdispatch.dylib 0x00000001964fc010 _dispatch_source_latch_and_call + 2052
>9 libdispatch.dylib 0x00000001964e7abc _dispatch_source_invoke + 288
>10 libdispatch.dylib 0x00000001964f2318 _dispatch_root_queue_drain + 720
>11 libdispatch.dylib 0x00000001964f3c4c _dispatch_worker_thread3 + 108
>12 libsystem_pthread.dylib 0x00000001966c522c _pthread_wqthread + 816
>13 libsystem_pthread.dylib 0x00000001966c4ef0 start_wqthread + 4
The [MStateDataAnalysis stopRecogniseTask] (MStateDataAnalysis.m:85) class line 85 is:
85 while (![_lock tryLock]) {
[NSThread sleepForTimeInterval:0.1];
}
_resultArray = nil;
_metroFlagArray = nil;
[_lock unlock];
The lock is:
#property(nonatomic, strong) NSLock * lock;
Because the _resultArray and _metroFlagArray is used in two thread,so I use lock。But I don't know what's wrong,there are small probability crash.
Related
I am getting a randomly occurring crash relating to the finishWritingWithCompletionHandler: method of AVAssetWriter.
This references roCleanupSampleBufferOperation and a
EXC_BAD_ACCESS KERN_INVALID_ADDRESS.
It occur very occasionally and is difficult to reproduce.
Here is the stack trace:
#12. Crashed: com.apple.avfoundation.videodataoutput.bufferqueue
0 libobjc.A.dylib 0x189db57f4 objc_object::release() + 8
1 CoreMedia 0x18dc5746c roCleanupSampleBufferOperation + 44
2 CoreMedia 0x18dc55f98 __FigRemoteOperationReceiverCreateMessageReceiver_block_invoke + 308
3 CoreMedia 0x18dc74e9c __FigRemoteQueueReceiverSetHandler_block_invoke.2 + 224
4 libdispatch.dylib 0x18a1ee9a0 _dispatch_client_callout + 16
5 libdispatch.dylib 0x18a1fb604 _dispatch_continuation_pop + 448
6 libdispatch.dylib 0x18a207c1c _dispatch_source_latch_and_call + 204
7 libdispatch.dylib 0x18a1f08a0 _dispatch_source_invoke + 804
8 libdispatch.dylib 0x18a1fc964 _dispatch_queue_serial_drain + 560
9 libdispatch.dylib 0x18a1f22cc _dispatch_queue_invoke + 884
10 libdispatch.dylib 0x18a1fc964 _dispatch_queue_serial_drain + 560
11 libdispatch.dylib 0x18a1f22cc _dispatch_queue_invoke + 884
12 libdispatch.dylib 0x18a1fd950 _dispatch_root_queue_drain_deferred_item + 256
13 libdispatch.dylib 0x18a204170 _dispatch_kevent_worker_thread + 760
14 libsystem_pthread.dylib 0x18a3f6fbc _pthread_wqthread + 772
15 libsystem_pthread.dylib 0x18a3f6cac start_wqthread + 4
#13. com.apple.root.user-interactive-qos
0 AppleJPEG 0x18cf856e8 aj_RGBA8888_YUV420 + 528
1 AppleJPEG 0x18cfa40e4 aj_col_trans_row + 172
2 AppleJPEG 0x18cf7be5c aj_encode_row + 136
3 AppleJPEG 0x18cfaca98 applejpeg_encode_image_row + 472
4 ImageIO 0x18d159c88 AppleJPEGWritePlugin::writeOne(IIOImagePixelDataProvider*, __CFDictionary const*) + 1708
5 ImageIO 0x18d159f50 AppleJPEGWritePlugin::writeAll() + 448
6 ImageIO 0x18d15a17c AppleJPEGWritePlugin::WriteProc(void*, __CFDictionary const*, __CFArray const*, __CFArray const*) + 84
7 ImageIO 0x18d0f1648 IIOImageDestination::finalize() + 556
8 ImageIO 0x18d0f28d0 CGImageDestinationFinalize + 76
9 UIKit 0x19172971c _UIImageJPEGRepresentation + 652
10 projectApp 0x100294e0c -[AVCamCaptureManager(InternalUtilityMethods) createThumbFromPath:] + 4296969740
11 projectApp 0x1002957ac -[AVCamCaptureManager(RecorderDelegate) recorder:recordingDidFinishToOutputFileURL:error:] + 4296972204
12 projectApp 0x100299008 __30-[AVCamRecorder stopRecording]_block_invoke + 4296986632
13 Foundation 0x18be0466c __103+[__NSOperationInternal _observeValueForKeyPath:ofObject:changeKind:oldValue:newValue:indexes:context:]_block_invoke.119 + 28
14 libdispatch.dylib 0x18a1ee9e0 _dispatch_call_block_and_release + 24
15 libdispatch.dylib 0x18a1ee9a0 _dispatch_client_callout + 16
16 libdispatch.dylib 0x18a1febac _dispatch_root_queue_drain + 888
17 libdispatch.dylib 0x18a1fe7d0 _dispatch_worker_thread3 + 124
18 libsystem_pthread.dylib 0x18a3f7100 _pthread_wqthread + 1096
19 libsystem_pthread.dylib 0x18a3f6cac start_wqthread + 4
And here is the code that is run when recording is completed:
[self.assetWriterVideoInput markAsFinished];
[self.assetWriter finishWritingWithCompletionHandler:^(void){
if ([[self delegate] respondsToSelector:#selector(recorder:recordingDidFinishToOutputFileURL:error:)]) {
NSError* error = nil;
[[self delegate] recorder:self recordingDidFinishToOutputFileURL:self.outputFileURL error:error];
}
}];
Any help much appreciated
(Update) Here is the delegate method:
-(void)recorder:(AVCamRecorder *)recorder recordingDidFinishToOutputFileURL:(NSURL *)outputFileURL error:(NSError *)error {
if (error) {
NSLog(#"recordingDidFinishToOutputFileURL received error: %#",error);
if ([[self delegate] respondsToSelector:#selector(captureManagerRecordingFinished:recordedVideo:)]) {
[[self delegate] captureManagerRecordingFinished:self recordedVideo:nil];
}
return;
}
[self createThumbFromPath:[ProjectSingleton getVideoPath:outputFileURL]];
if ([[self delegate] respondsToSelector:#selector(captureManagerRecordingFinished:recordedVideo:)]) {
[[self delegate] captureManagerRecordingFinished:self recordedVideo:[outputFileURL path]];
}
}
Thanks in advance if anybody can resolve my problem.
I am using NSURLSession API for network calls.
App is crashing on iOS9+ version.
See below crash thread:
Crashed: com.apple.NSURLSession-work 0 libobjc.A.dylib
0x1812f5b88 objc_msgSend + 8 1 CFNetwork
0x1822d6d4c + 56 2 CFNetwork
0x18235b718 + 40 3 libdispatch.dylib
0x1816c94bc + 24 4 libdispatch.dylib
0x1816c947c + 16 5 libdispatch.dylib
0x1816d54c0 + 864 6 libdispatch.dylib
0x1816ccf80 + 464 7 libdispatch.dylib
0x1816d7390 + 728 8 libdispatch.dylib
0x1816d70b0 + 112 9 libsystem_pthread.dylib
0x1818e1470 _pthread_wqthread + 1092 10 libsystem_pthread.dylib
0x1818e1020 start_wqthread + 4
I am getting the below error for swift app i made for IOS. I had setup notification using this example. How do I debug this and know what the issue is?
Crashed: com.apple.UNSNotificationRegistrarConnection
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000013000001328
Crashed: com.apple.UNSNotificationRegistrarConnection
0 libobjc.A.dylib 0x180cf9b9c objc_msgSend + 28
1 UserNotificationServices 0x183038b54 __destroy_helper_block_27 + 40
2 libsystem_blocks.dylib 0x1811298e8 _Block_release + 156
3 libdispatch.dylib 0x1810cd47c _dispatch_client_callout + 16
4 libdispatch.dylib 0x1810d94c0 _dispatch_queue_drain + 864
5 libdispatch.dylib 0x1810d0f80 _dispatch_queue_invoke + 464
6 libdispatch.dylib 0x1810cd47c _dispatch_client_callout + 16
7 libdispatch.dylib 0x1810db914 _dispatch_root_queue_drain + 2140
8 libdispatch.dylib 0x1810db0b0 _dispatch_worker_thread3 + 112
9 libsystem_pthread.dylib 0x1812e5470 _pthread_wqthread + 1092
10 libsystem_pthread.dylib 0x1812e5020 start_wqthread + 4
I am recording video in my app. My app crashes in iOS 7.0.x only. My application is crashing while writing the captured video in file. Below is my code to setup session & toggle camera
- (BOOL) setupSessionWithPreview:(UIView *)preview usingFrontCamera:(BOOL)frontCamera
{
AVCaptureDevice *videoDevice = nil;
if (frontCamera) {
videoDevice = [self getFrontCamera];
self.videoDeviceType = VideoDeviceTypeFrontCamera;
}
else {
videoDevice = [self getRearCamera];
self.videoDeviceType = VideoDeviceTypeRearCamera;
}
AVCaptureDevice *audioDevice = [self getAudioDevice];
self.videoInput = [[AVCaptureDeviceInput alloc] initWithDevice:videoDevice error:nil];
AVCaptureDeviceInput *audioInput = [[AVCaptureDeviceInput alloc] initWithDevice:audioDevice error:nil];
self.session = [[AVCaptureSession alloc] init];
if([self.session canAddInput:self.videoInput])
[self.session addInput:self.videoInput];
if([self.session canAddInput:audioInput])
[self.session addInput:audioInput];
self.audioOutput = [[AVCaptureAudioDataOutput alloc] init];
dispatch_queue_t audioCaptureQ = dispatch_queue_create("Audio Capture Q", DISPATCH_QUEUE_SERIAL);
[self.audioOutput setSampleBufferDelegate:self queue:audioCaptureQ];
if([self.session canAddOutput:self.audioOutput])
[self.session addOutput:self.audioOutput];
self.audioConnection = [self.audioOutput connectionWithMediaType:AVMediaTypeAudio];
self.videoOutput = [[AVCaptureVideoDataOutput alloc] init];
[self.videoOutput setAlwaysDiscardsLateVideoFrames:YES];
dispatch_queue_t videoCaptureQ = dispatch_queue_create("Video Capture Q", DISPATCH_QUEUE_SERIAL);
[self.videoOutput setSampleBufferDelegate:self queue:videoCaptureQ];
if([self.session canAddOutput:self.videoOutput])
[self.session addOutput:self.videoOutput];
self.videoConnection = [self.videoOutput connectionWithMediaType:AVMediaTypeVideo];
self.videoConnection.videoOrientation = AVCaptureVideoOrientationPortrait;
self.videoOrientation = [self.videoConnection videoOrientation];
movieWriterQ = dispatch_queue_create("Movie Writer Q", DISPATCH_QUEUE_SERIAL);
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session];
self.viewLayer = [preview layer];
[self.viewLayer setMasksToBounds:YES];
CGRect bounds = [preview bounds];
[self.previewLayer setFrame:bounds];
[self.previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[self.viewLayer insertSublayer:self.previewLayer below:[[self.viewLayer sublayers] objectAtIndex:0]];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self.session startRunning];
});
return YES;
}
// Code to toggle camera
-(void)toggleCameraIsFront:(BOOL)isFront
{
AVCaptureDevicePosition desiredPosition;
if (isFront) {
desiredPosition = AVCaptureDevicePositionFront;
self.videoDeviceType = VideoDeviceTypeFrontCamera;
}
else {
desiredPosition = AVCaptureDevicePositionBack;
self.videoDeviceType = VideoDeviceTypeRearCamera;
}
NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *device in videoDevices)
{
if ([device position] == desiredPosition)
{
AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];
[self.session beginConfiguration];
[self.session removeInput:self.videoInput];
if ([self.session canAddInput:videoDeviceInput])
{
[self.session addInput:videoDeviceInput];
[self setVideoInput:videoDeviceInput];
}
else
{
[self.session addInput:self.videoInput];
}
[self.session removeOutput:self.videoOutput];
AVCaptureVideoDataOutput *videoDeviceOutput = [[AVCaptureVideoDataOutput alloc] init];
if ([self.session canAddOutput:videoDeviceOutput])
{
[self.session addOutput:videoDeviceOutput];
[self setVideoOutput:videoDeviceOutput];
[self.videoOutput setAlwaysDiscardsLateVideoFrames:YES];
// How to manage previously created videoCaptureQ in setupSessionWithPreview method ???
// or do we need create instance variable as dispatch_queue_t videoCaptureQ ???
dispatch_queue_t videoCaptureQ = dispatch_queue_create("Video Capture Q", DISPATCH_QUEUE_SERIAL);
[self.videoOutput setSampleBufferDelegate:self queue:videoCaptureQ];
self.videoConnection = [self.videoOutput connectionWithMediaType:AVMediaTypeVideo];
self.videoConnection.videoOrientation = AVCaptureVideoOrientationPortrait;
self.videoOrientation = [self.videoConnection videoOrientation];
}
else
{
[self.session addOutput:self.videoOutput];
}
[self.session commitConfiguration];
break;
}
}
}
// Code responsible for crashing in iOS 7.0.x ONLY, Works perfectly with iOS 6.x & iOS 7.1
#property(nonatomic, retain) AVAssetWriter *writer;
#property(nonatomic, retain) AVAssetReader *reader;
#property(nonatomic, retain) AVAssetReaderVideoCompositionOutput *videoOut;
#property(nonatomic, retain) AVAssetReaderOutput *audioOut;
#property(nonatomic, retain) AVAssetWriterInput *videoIn;
#property(nonatomic, retain) AVAssetWriterInput *audioIn;
dispatch_group_enter(self.dispatchGroup);
[self.videoIn requestMediaDataWhenReadyOnQueue:self.videoWriterQ usingBlock:^(void) {
if(self.videoFinished)
return;
BOOL completedOrFailed = NO;
while([self.videoIn isReadyForMoreMediaData] && !completedOrFailed)
{
// App crashes here .
CMSampleBufferRef sample = [self.videoOut copyNextSampleBuffer];
if(sample != NULL)
{
BOOL bret = [self.videoIn appendSampleBuffer:sample];
CFRelease(sample);
sample = NULL;
completedOrFailed = !bret;
}
else
{
completedOrFailed = YES;
}
}
if(completedOrFailed)
{
if(!self.videoFinished)
{
[self.videoIn markAsFinished];
}
self.videoFinished = YES;
dispatch_group_leave(self.dispatchGroup);
}
}];
Here is the crash log
Date/Time: 2014-04-07 11:05:34.917 +0100
OS Version: iOS 7.0.6 (11B651)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x7176d7e0
Triggered by Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x3848bb26 objc_msgSend + 6
1 AVFoundation 0x2cf78650 -[AVCaptureVideoDataOutput _applyOverridesToCaptureOptions:] + 168
2 AVFoundation 0x2cf7081c -[AVCaptureSession _resolvedCaptureOptionsByApplyingOverridesToCaptureOptions:preset:] + 344
3 AVFoundation 0x2cf70b2c -[AVCaptureSession _resolvedCaptureOptionsForPreset:audioDevice:videoDevice:] + 108
4 AVFoundation 0x2cf7235c -[AVCaptureSession _buildAndRunGraph] + 312
5 AVFoundation 0x2cf6cc3c -[AVCaptureSession removeInput:] + 1008
6 AVFoundation 0x2cf6ae0c -[AVCaptureSession dealloc] + 172
7 Foundation 0x2e9d1a44 NSKVODeallocate + 60
8 libobjc.A.dylib 0x3849bb06 objc_object::sidetable_release(bool) + 170
9 libobjc.A.dylib 0x3848d002 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 354
10 QuartzCore 0x3043e864 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 64
11 CoreFoundation 0x2e01b1ca __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
12 CoreFoundation 0x2e018b6c __CFRunLoopDoObservers + 280
13 CoreFoundation 0x2e018eae __CFRunLoopRun + 726
14 CoreFoundation 0x2df83c22 CFRunLoopRunSpecific + 518
15 CoreFoundation 0x2df83a06 CFRunLoopRunInMode + 102
16 GraphicsServices 0x32caa27e GSEventRunModal + 134
17 UIKit 0x30827044 UIApplicationMain + 1132
18 AppName 0x0013ed06 main (main.m:17)
19 libdyld.dylib 0x38998ab4 start + 0
Thread 1:
0 libsystem_kernel.dylib 0x38a3c83c kevent64 + 24
1 libdispatch.dylib 0x3897d210 _dispatch_mgr_invoke + 228
2 libdispatch.dylib 0x3897cf96 _dispatch_mgr_thread$VARIANT$mp + 34
Thread 2 name: com.apple.NSURLConnectionLoader
Thread 2:
0 libsystem_kernel.dylib 0x38a3ca8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x38a3c888 mach_msg + 44
2 CoreFoundation 0x2e01a7be __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x2e018ee4 __CFRunLoopRun + 780
4 CoreFoundation 0x2df83c22 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x2df83a06 CFRunLoopRunInMode + 102
6 Foundation 0x2e9be2f2 +[NSURLConnection(Loader) _resourceLoadLoop:] + 314
7 Foundation 0x2ea33c82 __NSThread__main__ + 1058
8 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
9 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
10 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 3 name: com.apple.CFSocket.private
Thread 3:
0 libsystem_kernel.dylib 0x38a4f440 __select + 20
1 CoreFoundation 0x2e01e680 __CFSocketManager + 480
2 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
3 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
4 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 4 name: AFNetworking
Thread 4:
0 libsystem_kernel.dylib 0x38a3ca8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x38a3c888 mach_msg + 44
2 CoreFoundation 0x2e01a7be __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x2e018ee4 __CFRunLoopRun + 780
4 CoreFoundation 0x2df83c22 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x2df83a06 CFRunLoopRunInMode + 102
6 Foundation 0x2e9713d6 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7 Foundation 0x2e9c230c -[NSRunLoop(NSRunLoop) run] + 76
8 AppName 0x001637b6 +[AFURLConnectionOperation networkRequestThreadEntryPoint:] (AFURLConnectionOperation.m:184)
9 Foundation 0x2ea33c82 __NSThread__main__ + 1058
10 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
11 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
12 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 5 name: com.apple.coremedia.player.async
Thread 5:
0 libsystem_kernel.dylib 0x38a3cadc semaphore_wait_trap + 8
1 libdispatch.dylib 0x3897b428 _dispatch_semaphore_wait_slow + 172
2 MediaToolbox 0x2f46f83c fpa_AsyncMovieControlThread + 1752
3 CoreMedia 0x2e5ae234 figThreadMain + 192
4 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
5 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
6 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 6:
0 libsystem_kernel.dylib 0x38a3ca8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x38a3c888 mach_msg + 44
2 CoreFoundation 0x2e01a7be __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x2e018ee4 __CFRunLoopRun + 780
4 CoreFoundation 0x2df83c22 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x2df83a06 CFRunLoopRunInMode + 102
6 libAVFAudio.dylib 0x2d006584 GenericRunLoopThread::Entry(void*) + 124
7 libAVFAudio.dylib 0x2cffa99c CAPThread::Entry(CAPThread*) + 176
8 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
9 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
10 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 7 name: com.apple.coremedia.player.async
Thread 7:
0 libsystem_kernel.dylib 0x38a3cadc semaphore_wait_trap + 8
1 libdispatch.dylib 0x3897b428 _dispatch_semaphore_wait_slow + 172
2 MediaToolbox 0x2f46f83c fpa_AsyncMovieControlThread + 1752
3 CoreMedia 0x2e5ae234 figThreadMain + 192
4 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
5 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
6 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 8 name: com.apple.coremedia.player.remote
Thread 8:
0 libsystem_kernel.dylib 0x38a3ca8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x38a3c888 mach_msg + 44
2 MediaToolbox 0x2f475c58 FigExpressNotificationThread + 84
3 CoreMedia 0x2e5ae234 figThreadMain + 192
4 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
5 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
6 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 9:
0 libsystem_kernel.dylib 0x38a3ca8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x38a3c888 mach_msg + 44
2 CoreFoundation 0x2e01a7be __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x2e018ee4 __CFRunLoopRun + 780
4 CoreFoundation 0x2df83c22 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x2dfc7736 CFRunLoopRun + 94
6 CoreMotion 0x2e63a230 ___lldb_unnamed_function1404$$CoreMotion + 724
7 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
8 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
9 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 10 name: com.apple.coremedia.player.async
Thread 10:
0 libsystem_kernel.dylib 0x38a3cadc semaphore_wait_trap + 8
1 libdispatch.dylib 0x3897b428 _dispatch_semaphore_wait_slow + 172
2 MediaToolbox 0x2f46f83c fpa_AsyncMovieControlThread + 1752
3 CoreMedia 0x2e5ae234 figThreadMain + 192
4 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
5 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
6 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 11:
0 libsystem_kernel.dylib 0x38a4fc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38ab5dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38ab5c80 start_wqthread + 4
Thread 12:
0 libsystem_kernel.dylib 0x38a4fc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38ab5dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38ab5c80 start_wqthread + 4
Thread 13:
0 libsystem_kernel.dylib 0x38a3ca8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x38a3c888 mach_msg + 44
2 MediaToolbox 0x2f588594 FigRemakerFamilyClient_ReaderExtractAndRetainNextSampleBuffer + 92
3 MediaToolbox 0x2f5835a0 remoteReader_ExtractAndRetainNextSampleBuffer + 108
4 AVFoundation 0x2cf2a8ba -[AVAssetReaderOutput copyNextSampleBuffer] + 222
5 AppName 0x0016a320 __36-[MediaWriter performWrite:onError:]_block_invoke141 (MediaWriter.m:188)
6 AVFoundation 0x2cf3d810 -[AVAssetWriterInputMediaDataRequester requestMediaDataIfNecessary] + 84
7 libdispatch.dylib 0x38973d18 _dispatch_call_block_and_release + 8
8 libdispatch.dylib 0x3897a26e _dispatch_queue_drain$VARIANT$mp + 370
9 libdispatch.dylib 0x3897a066 _dispatch_queue_invoke$VARIANT$mp + 38
10 libdispatch.dylib 0x3897acde _dispatch_root_queue_drain + 74
11 libdispatch.dylib 0x3897af54 _dispatch_worker_thread2 + 52
12 libsystem_pthread.dylib 0x38ab5dbc _pthread_wqthread + 296
13 libsystem_pthread.dylib 0x38ab5c80 start_wqthread + 4
Thread 14 name: com.apple.coremedia.player.async
Thread 14:
0 libsystem_kernel.dylib 0x38a3cadc semaphore_wait_trap + 8
1 libdispatch.dylib 0x3897b428 _dispatch_semaphore_wait_slow + 172
2 MediaToolbox 0x2f46f83c fpa_AsyncMovieControlThread + 1752
3 CoreMedia 0x2e5ae234 figThreadMain + 192
4 libsystem_pthread.dylib 0x38ab7c1a _pthread_body + 138
5 libsystem_pthread.dylib 0x38ab7b8a _pthread_start + 98
6 libsystem_pthread.dylib 0x38ab5c8c thread_start + 4
Thread 15:
0 libsystem_kernel.dylib 0x38a4fc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38ab5dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38ab5c80 start_wqthread + 4
Thread 16:
0 libsystem_kernel.dylib 0x38a4fc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38ab5dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38ab5c80 start_wqthread + 4
Thread 17:
0 libsystem_kernel.dylib 0x38a3ca8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x38a3c888 mach_msg + 44
2 MediaToolbox 0x2f5896b4 FigRemakerFamilyClient_WriterAddSampleBuffer + 112
3 MediaToolbox 0x2f581bec remoteWriter_AddSampleBuffer + 236
4 AVFoundation 0x2cf3c144 -[AVFigAssetWriterTrack addSampleBuffer:error:] + 84
5 AVFoundation 0x2cf3cfcc -[AVFigAssetWriterAudioTrack addSampleBuffer:error:] + 300
6 AVFoundation 0x2cf39afa -[AVAssetWriterInputWritingHelper appendSampleBuffer:] + 74
7 AVFoundation 0x2cf37d62 -[AVAssetWriterInput appendSampleBuffer:] + 46
8 AppName 0x0016a190 __36-[MediaWriter performWrite:onError:]_block_invoke (MediaWriter.m:162)
9 AVFoundation 0x2cf3d810 -[AVAssetWriterInputMediaDataRequester requestMediaDataIfNecessary] + 84
10 libdispatch.dylib 0x38973d18 _dispatch_call_block_and_release + 8
11 libdispatch.dylib 0x3897a26e _dispatch_queue_drain$VARIANT$mp + 370
12 libdispatch.dylib 0x3897a066 _dispatch_queue_invoke$VARIANT$mp + 38
13 libdispatch.dylib 0x3897acde _dispatch_root_queue_drain + 74
14 libdispatch.dylib 0x3897af54 _dispatch_worker_thread2 + 52
15 libsystem_pthread.dylib 0x38ab5dbc _pthread_wqthread + 296
16 libsystem_pthread.dylib 0x38ab5c80 start_wqthread + 4
Thread 18:
0 libsystem_kernel.dylib 0x38a3e664 fsync + 8
1 libsqlite3.dylib 0x3876d73c ___lldb_unnamed_function199$$libsqlite3.dylib + 44
2 libsqlite3.dylib 0x387a59e8 ___lldb_unnamed_function529$$libsqlite3.dylib + 1168
3 libsqlite3.dylib 0x3876d138 ___lldb_unnamed_function197$$libsqlite3.dylib + 336
4 libsqlite3.dylib 0x38763004 ___lldb_unnamed_function156$$libsqlite3.dylib + 552
5 libsqlite3.dylib 0x38744638 ___lldb_unnamed_function56$$libsqlite3.dylib + 1496
6 libsqlite3.dylib 0x3875fc32 ___lldb_unnamed_function123$$libsqlite3.dylib + 38026
7 libsqlite3.dylib 0x38755e2c sqlite3_step + 404
8 libsqlite3.dylib 0x38734952 sqlite3_exec + 358
9 CFNetwork 0x2dc14d30 __CFURLCache::ExecSQLStatement_NoLock(sqlite3*, char const*, int (*)(void*, int, char**, char**), void*, long) + 32
10 CFNetwork 0x2dc84bb8 __CFURLCache::_PreProcessCacheTasks() + 108
11 CFNetwork 0x2dc849da __CFURLCache::_CFURLCacheTimerCallback0() + 630
12 CFNetwork 0x2dc84754 __CFURLCache::_CFURLCacheTimerCallback(void*) + 28
13 libdispatch.dylib 0x3897c7fe _dispatch_source_invoke$VARIANT$mp + 258
14 libdispatch.dylib 0x3897a232 _dispatch_queue_drain$VARIANT$mp + 310
15 libdispatch.dylib 0x3897a066 _dispatch_queue_invoke$VARIANT$mp + 38
16 libdispatch.dylib 0x3897acde _dispatch_root_queue_drain + 74
17 libdispatch.dylib 0x3897af54 _dispatch_worker_thread2 + 52
18 libsystem_pthread.dylib 0x38ab5dbc _pthread_wqthread + 296
19 libsystem_pthread.dylib 0x38ab5c80 start_wqthread + 4
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x176f9f60 r1: 0x30daa1e8 r2: 0x2cfeb38f r3: 0x00000000
r4: 0x30dba133 r5: 0x18e7bde0 r6: 0x30dad051 r7: 0x27d087f8
r8: 0x38b3fc28 r9: 0x7176d7d4 r10: 0x1903c100 r11: 0x18fdbd70
ip: 0x38b1e868 sp: 0x27d087c4 lr: 0x2cf78655 pc: 0x3848bb26
cpsr: 0x60000030
Can anybody tell me what's going wrong in iOS 7.0.x ONLY ? On other iOS versions its working correctly. Any kind of help is appreciated.
Thanks.
Did you dealloc correctly?
Try adding these lines to your dealloc method,
[self.session removeInput:self.videoIn];
[self.session removeOutput:self.videoOut];
My iOS app is crashing when doing two calls to countForFetchRequest at the same time on the same private queue NSManagedObjectContext using performBlock.
I setup my childContext like this
_childContext = [[NSManagedObjectContext alloc]initWithConcurrencyType:NSPrivateQueueConcurrencyType];
[_childContext setParentContext:self.managedObjectContext];
And this is my performBlock that calls countForFetchRequest
[self.childContext performBlock:^{
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:#"History"];
fetchRequest.predicate = [NSPredicate predicateWithFormat:#"url == %#", url];
NSError *error = nil;
NSUInteger num = [self.childContext countForFetchRequest:fetchRequest error:&error];
if(error != nil){
NSLog(#"Error getting count for history url %# %#", url, error);
return;
}
if(num > 0){ // Already have this in the history, don't re-add it
return;
}
History *history = (History *)[NSEntityDescription insertNewObjectForEntityForName:#"History" inManagedObjectContext:self.childContext];
history.url = url;
history.title = title;
if(![self.childContext save:&error]){
NSLog(#"Error occurred saving history item %# %# %#", title, url, error);
}
}];
And here is the crash log:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3a427350 __pthread_kill + 8
1 libsystem_c.dylib 0x3a39e11e pthread_kill + 54
2 libsystem_c.dylib 0x3a3da96e abort + 90
3 libc++abi.dylib 0x39978d4a abort_message + 70
4 libc++abi.dylib 0x39975ff4 default_terminate() + 20
5 libobjc.A.dylib 0x39f29a74 _objc_terminate() + 144
6 libc++abi.dylib 0x39976078 safe_handler_caller(void (*)()) + 76
7 libc++abi.dylib 0x39976110 std::terminate() + 16
8 libc++abi.dylib 0x39977594 __cxa_rethrow + 84
9 libobjc.A.dylib 0x39f299cc objc_exception_rethrow + 8
10 CoreData 0x31e868e0 -[NSManagedObjectContext(_NSInternalAdditions) _countWithNoChangesForRequest:error:] + 764
11 CoreData 0x31e833fe -[NSManagedObjectContext countForFetchRequest:error:] + 1062
12 CoreData 0x31e92470 __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke_0 + 460
13 libdispatch.dylib 0x3a345d26 _dispatch_barrier_sync_f_slow_invoke + 82
14 libdispatch.dylib 0x3a3404b4 _dispatch_client_callout + 20
15 libdispatch.dylib 0x3a3451b8 _dispatch_main_queue_callback_4CF$VARIANT$mp + 220
16 CoreFoundation 0x3205cf36 __CFRunLoopRun + 1286
17 CoreFoundation 0x31fcfeb8 CFRunLoopRunSpecific + 352
18 CoreFoundation 0x31fcfd44 CFRunLoopRunInMode + 100
19 GraphicsServices 0x35b992e6 GSEventRunModal + 70
20 UIKit 0x33ee52fc UIApplicationMain + 1116
21 Accountable2You Mobile 0x000e5d28 0xe4000 + 7464
22 Accountable2You Mobile 0x000e5cc4 0xe4000 + 7364
Thread 1 name: Dispatch queue: NSManagedObjectContext Queue
Thread 1:
0 libsystem_kernel.dylib 0x3a416f04 semaphore_wait_trap + 8
1 libdispatch.dylib 0x3a3462fc _dispatch_thread_semaphore_wait$VARIANT$mp + 8
2 libdispatch.dylib 0x3a34487c _dispatch_barrier_sync_f_slow + 96
3 CoreData 0x31e82df2 _perform + 166
4 CoreData 0x31e921c6 -[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:] + 238
5 CoreData 0x31e86770 -[NSManagedObjectContext(_NSInternalAdditions) _countWithNoChangesForRequest:error:] + 396
6 CoreData 0x31e833fe -[NSManagedObjectContext countForFetchRequest:error:] + 1062
7 Accountable2You Mobile 0x000ee7be 0xe4000 + 42942
8 CoreData 0x31e86072 developerSubmittedBlockToNSManagedObjectContextPerform_privateasync + 66
9 libdispatch.dylib 0x3a344eca _dispatch_queue_drain$VARIANT$mp + 138
10 libdispatch.dylib 0x3a344dbc _dispatch_queue_invoke$VARIANT$mp + 36
11 libdispatch.dylib 0x3a34591a _dispatch_root_queue_drain + 182
12 libdispatch.dylib 0x3a345abc _dispatch_worker_thread2 + 80
13 libsystem_c.dylib 0x3a375a0e _pthread_wqthread + 358
14 libsystem_c.dylib 0x3a3758a0 start_wqthread + 4
Am I using the performBlock correctly?
Edit: More details
The performBlock is being called in a webViewDidFinishLoad:webView delegate method. I have multiple UIWebViews and when they finish loading they are calling the delegate method which is in turn calling the performBlock to see if it needs to add the url to the core data database.
You can encapsulate the method causing the crash in:
#synchronized(self) {
[object yourMethod];
}
This will make sure that even while multithreading, the piece of code inside will be running just once at a time ... other threads will just have to wait. Frankly, this will work only if the cause of the crash is the concurrency.