1

我的应用程序在 iPhone 5S 上崩溃,而不是在任何其他设备上崩溃,它指向 startRecordingToOutputFileURL:recordingDelegate 中引发的异常:

   Date/Time:           2013-11-01 13:18:03.672 -0400
   OS Version:          iOS 7.0.3 (11B511)
   Report Version:      104

   Exception Type:  EXC_CRASH (SIGABRT)
   Exception Codes: 0x0000000000000000, 0x0000000000000000
   Triggered by Thread:  0

    Last Exception Backtrace:
    0   CoreFoundation                  0x2f164e83 __exceptionPreprocess + 131
    1   libobjc.A.dylib                 0x394c56c7 objc_exception_throw + 38
    2   AVFoundation                    0x2e0679b9 -[AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] + 512

我没有要测试的 iPhone 5S,也不想为了这个目的而买一个。我检查了明显的错误,例如 nil 文件 URL、nil 委托,但没有一个被命中。

我该如何调试,有什么想法吗?是否有可能进行远程测试并从 beta 测试人员的设备中提取日志?我检查了大多数日志提取应用程序都无法在 iOS 7 上运行。

编辑:我强烈怀疑它与我设置 AVCaptureDevice 的方式有关。这是我的代码,请指出我是否正确。

这是我设置设备输入的方法。

    AVCaptureDeviceFormat *bestFormat = nil;

    CMVideoDimensions bestDimensions = {0.f, 0.f};
    CMVideoDimensions dimensions;

    NSInteger width = [self videoTrackWidth];
    NSInteger height = [self videoTrackHeight];

    NSInteger fps = [[self currentFPSFromSettings] integerValue];

    if (fps > 30) {
        [self configureCameraForHighFrameRate:device]; //No crash if this path is executed
    } else {
    /* crashes only if this path is executed */
        for ( AVCaptureDeviceFormat *format in [device formats] ) {
            CMFormatDescriptionRef formatDesc = [format formatDescription];
            dimensions = CMVideoFormatDescriptionGetDimensions(formatDesc);

            if (dimensions.width >= width && dimensions.height >= height) {
                for ( AVFrameRateRange *range in format.videoSupportedFrameRateRanges ) {
                    if (range.maxFrameRate >= fps) {
                        bestDimensions = dimensions;
                        bestFormat = format;
                        MPLog(@" -- Max FPS = %f", range.maxFrameRate);
                        break;
                    }
                }
            }
        }

        if (!bestFormat) {
            bestFormat = [[device formats] lastObject];
        }

        if ( bestFormat ) {
            if ( [device lockForConfiguration:NULL] == YES ) {
                device.activeFormat = bestFormat;
                MPLog(@"Device Max Zoom = %f", bestFormat.videoMaxZoomFactor);
                self.maxZoomSupportedByDevice = bestFormat.videoMaxZoomFactor;
                [device unlockForConfiguration];
            }
        }
    }
4

2 回答 2

0

最终发现问题源代码中所述的手动配置AVCaptureSession的方法存在问题。在代码中,我试图找到支持 30 fps 并具有最高视觉尺寸的 AVCaptureDeviceFormat。我假设任何格式可以支持 30 fps 的最高尺寸是 1920x1080,但 iPhone 5s 是第一款支持全 8 兆像素采样缓冲区 @30 fps 的设备。并且 AVCaptureMovieFileOutput 无法使用 8 MP 样本缓冲区进行编码并崩溃!

于 2014-10-03T17:48:27.057 回答
0

我遇到过同样的问题。创建 AVCaptureSession 时,我的应用程序在 iPhone 5s 上崩溃了。检查我在 iTunes Connect 中的构建,我发现它在 Supported Architectures 下只有 armv7。可能当我第一次创建存档时,我将 iPhone 5c 连接到 Xcode,但在没有连接手机的情况下再次创建它会创建一个同时支持 armv7 和 arm64 的新版本。现在相同的代码可以在 iPhone 5s 上运行。

于 2014-09-22T16:30:56.507 回答