AVWeakReferencingDelegateStorage:委托序列化队列

时间:2016-10-06 23:10:36

标签: ios ios10

自iOS 10更新以来,我目前遇到了一个新的iOS应用程序问题。该问题仅发生在iOS 10及更高版本的设备上。完整的崩溃日志如下:

Crashed: <AVWeakReferencingDelegateStorage: 0x170229fc0> delegate serialization queue
0  libdispatch.dylib              0x18f8121e8 _os_object_retain + 72
1  libdispatch.dylib              0x18f8111c0 _dispatch_client_callout + 16
2  libdispatch.dylib              0x18f822584 _dispatch_non_barrier_sync_f_invoke + 84
3  AVFoundation                   0x1980e33ec -[AVWeakReferencingDelegateStorage getRetainedDelegate:retainedDelegateQueue:] + 168
4  AVFoundation                   0x1980e3240 -[AVWeakReferencingDelegateStorage delegate] + 36
5  AVFoundation                   0x1980ce244 -[AVCaptureVideoDataOutput _handleRemoteQueueOperation:] + 76
6  AVFoundation                   0x1980ce168 __47-[AVCaptureVideoDataOutput _updateRemoteQueue:]_block_invoke + 100
7  CoreMedia                      0x1932a0da8 __FigRemoteOperationReceiverCreateMessageReceiver_block_invoke + 260
8  CoreMedia                      0x1932c0020 __FigRemoteQueueReceiverSetHandler_block_invoke.2 + 216
9  libdispatch.dylib              0x18f8111c0 _dispatch_client_callout + 16
10 libdispatch.dylib              0x18f81e008 _dispatch_continuation_pop + 576
11 libdispatch.dylib              0x18f82a648 _dispatch_source_latch_and_call + 204
12 libdispatch.dylib              0x18f813164 _dispatch_source_invoke + 820
13 libdispatch.dylib              0x18f81f278 _dispatch_queue_serial_drain + 468
14 libdispatch.dylib              0x18f8149a8 _dispatch_queue_invoke + 652
15 libdispatch.dylib              0x18f81f278 _dispatch_queue_serial_drain + 468
16 libdispatch.dylib              0x18f8149a8 _dispatch_queue_invoke + 652
17 libdispatch.dylib              0x18f8202ac _dispatch_root_queue_drain_deferred_item + 248
18 libdispatch.dylib              0x18f826b0c _dispatch_kevent_worker_thread + 816
19 libsystem_pthread.dylib        0x18fa19174 _pthread_wqthread + 948
20 libsystem_pthread.dylib        0x18fa18db4 start_wqthread + 4

我在我的代码中发现了代码崩溃的原因,但我现在知道导致它在iOS 10设备上崩溃的原因。 附:它不会在所有iOS 10+设备上崩溃。

代码如下:

- (void)forwardToResultsVC:(NSDictionary *)results
{
    self.successfulTestResults = results;

    NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
    [self.petTest updateTestWithTestElementParameters:results];
    [localContext MR_saveOnlySelfAndWait];
    [self performSegueWithIdentifier:kTestAnalyzeSeguge sender:nil];

    // Log successful test and time it took to take (Parse)
    NSDate *testCompleteDate = [NSDate date];
    NSTimeInterval timeToTakeTest = [testCompleteDate timeIntervalSinceDate:self.testStartDate];
    NSDictionary *params = @{ kPetnosticsAnalyticsTimeToTakeSuccesfulTest : [NSString stringWithFormat:@"%f", timeToTakeTest]};
    [PFAnalytics trackEvent:kPetnosticsAnalyticsTestSuccesfullyCompleted dimensions:params];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:kTestResultsSeguge]) {
        SPResultsViewController *resultsVC = segue.destinationViewController;
        resultsVC.test = self.petTest;
        resultsVC.ogHarrisFoundPointsImage = self.ogHarrisFoundPointsImage;
        resultsVC.foundTestPointsImage = self.foundTestPointsImage;
        resultsVC.analysisImage = self.analysisImage;
        resultsVC.croppedStripImage = self.croppedStripImage;
        resultsVC.test = self.petTest;
    } else if ([segue.identifier isEqualToString:kTestAnalyzeSeguge]) {
        SPAnalyzingViewController *analyzingVC = segue.destinationViewController;
        analyzingVC.pet = self.pet;
        analyzingVC.test = self.petTest;
        analyzingVC.ogHarrisFoundPointsImage = self.ogHarrisFoundPointsImage;
        analyzingVC.foundTestPointsImage = self.foundTestPointsImage;
        analyzingVC.analysisImage = self.analysisImage;
        analyzingVC.croppedStripImage = self.croppedStripImage;
        analyzingVC.backingCard = self.backingCard;
        if (self.testMethod == nil) {
            self.testMethod = @"Cup";
        }
        analyzingVC.testMethod = self.testMethod;
    } 
}

然后segue会提示以下内容:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self saveTestUploadImage];
}

- (void)saveTestUploadImage
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
        UIImage *debugImage = self.foundTestPointsImage;
        NSData *testImageData = nil;
        if (debugImage) {
            [debugImage saveImageTofileName:@"testImage.jpg"];
            testImageData = UIImageJPEGRepresentation(debugImage, 1);
        }
        if ([testImageData length] > 0) {
            PFFile *imageFile = [PFFile fileWithName:@"testImage.jpg" data:testImageData];
            [self uploadTestDataWithImage:imageFile];
        } else {
            // No Test Image Data... hmm...
            [PFAnalytics trackEvent:@"SPTestNoImageFound"];
            [self uploadTestDataWithImage:nil];
        }
    });
}

但是,它会在调用saveTestUploadImage之前崩溃。 有任何想法吗?先谢谢你。

1 个答案:

答案 0 :(得分:3)

在跟踪中看到AVCaptureVideoDataOutput,您是否在plist文件中添加了相应的授权? NSCameraUsageDescriptionNSPhotoLibraryUsageDescription,尤其是NSMicrophoneUsageDescription,似乎确实会让应用崩溃,并且会显示正确的崩溃信息。