首页 > 解决方案 > 带有 AVCaptureVideoDataOutput 的 iOS 应用程序在 App Store 版本中崩溃

问题描述

我有一个使用相机的应用程序。在上一个版本中,我将相机控件移到了一个新类中,它在 App Store 版本中开始崩溃,除了第一次运行。通过 Xcode 安装时,该应用程序按预期工作。

我有以下功能来进行配置。

func performConfiguration(block: @escaping (() -> Void)) {
    sessionQueue.async { () -> Void in
        block()
    }
}

应用程序在我检查是否可以将视频输出添加到会话的行中崩溃(下面的第 6 行):

func configureVideoOutput() {
    performConfiguration { () -> Void in
        self.videoOutput = AVCaptureVideoDataOutput()
        self.videoOutput.setSampleBufferDelegate(self.delegate_voutput, queue: DispatchQueue(label: "sample buffer delegate"))

        if self.session.canAddOutput(self.videoOutput) {
            self.session.addOutput(self.videoOutput)
            let connection = self.videoOutput.connection(with: .video)
            connection?.videoOrientation = .portrait
        }
    }
}

这是 delegate_voutput 代码:

    weak var delegate_voutput: AVCaptureVideoDataOutputSampleBufferDelegate?

我将视图控制器中的 delegate_voutput 设置为“self”并实现委托功能。

这是来自 App Store 的崩溃日志:

0  MyApp                          0x1003b921c closure #1 in CameraController.configureVideoOutput()
1  MyApp                          0x1003b9e90 partial apply for closure #1 in CameraController.performConfiguration(block:)
2  MyApp                          0x1003bd2c8 thunk for @escaping @callee_guaranteed () -> ()
3  libdispatch.dylib              0x192ff8304 _dispatch_call_block_and_release

我已经添加NSCameraUsageDescription到 info.plist 以及本地化版本(InfoPlist.strings),以防这是原因..

我不确定第一次启动时具体是什么,因为硬盘驱动器中没有存储与配置相关的任何内容。

有没有办法在不提交应用程序进行审核的情况下测试 App Store 行为?TestFlight 会给出相同的行为吗?

编辑:这是sessionQueue在中声明的方式CameraController.swift

private var sessionQueue = DispatchQueue(label: "com.mikrasya.myapp")

标签: iosswiftxcodeavfoundation

解决方案


我按照解决崩溃的 Apple AVCam 示例代码更改了应用程序的架构。

为什么 App 在使用 Xcode 安装时可以正常但在 App Store 版本中崩溃仍然是个谜。


推荐阅读