【问题标题】:AVCaptureSession Crashing when using webRTC使用 webRTC 时 AVCaptureSession 崩溃
【发布时间】:2017-07-21 05:49:26
【问题描述】:

我使用的是WebRTC,它使用的是AVCaptureSession。它可以正常工作几次,但有时会因此异常而崩溃。

断言失败:(_internal->figCaptureSession == NULL),函数 -[AVCaptureVideoPreviewLayer attachToFigCaptureSession:],文件/BuildRoot/Library/Caches/com.apple.xbs/Sources/EmbeddedAVFoundation/EmbeddedAVFoundation-1187.37.2.1/Aspen/AVCaptureVideoPreviewLayer.m

【问题讨论】:

  • 这里也一样,只是随机发生,没有有用的调试信息。
  • @蒂娜。能否添加更多集成代码、版本 WebRTC 库和完整堆栈跟踪?
  • @Tina 你解决了吗?
  • 同样的问题,有人找到解决办法了吗?

标签: webrtc avcapturesession


【解决方案1】:

我最近也遇到了这个问题。在我的代码中,我保留了一个 AVCaptureOutput 实例并添加和删除了它。再次尝试将相同的 AVCaptureOutput 实例添加到相同的捕获会话时,出现此错误。

我就是这样解决的:

private var _captureOutput: AVCaptureOutput?
var captureOutput: AVCaptureOutput {
    guard let captureOutput = _captureOutput else {
        let photoOutput = AVCapturePhotoOutput()
        photoOutput.isHighResolutionCaptureEnabled = true
        _captureOutput = photoOutput
        return photoOutput
    }
    return captureOutput
}

在需要时初始化实例一次,在删除时也将其无效。

captureSession.outputs.forEach { [weak self] output in
    self?.captureSession.removeOutput(output)
    self?._captureOutput = nil
}

【讨论】:

    【解决方案2】:

    在使用 RTCCameraPreviewView 实例之前,您必须取消它的 captureSession 并且断言将消失。面临同样的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多