Swift-奇怪的“金属”崩溃

时间:2018-12-21 13:40:08

标签: swift camera buffer metal

当我为相机启动此代码时,我有一个随机的怪异崩溃。 错误消息指向以下行: videoPreviewView.bindDrawable()

func setupVideoPreviewView() {
        glContext = EAGLContext(api: .openGLES2)
        if let eaglContext = glContext {
            videoPreviewView = GLKView(frame: self.view.bounds, context: eaglContext)
            ciContext = CIContext(eaglContext: eaglContext)
        }
        if let videoPreviewView = videoPreviewView {
            videoPreviewView.enableSetNeedsDisplay = false
            videoPreviewView.frame = self.view.bounds
            videoPreviewView.isUserInteractionEnabled = false

            self.view.addSubview(videoPreviewView)
            self.view.sendSubview(toBack: videoPreviewView)
        }

        resizePreviewView()
    }

    // MARK: Update
    func resizePreviewView() {
        guard let videoPreviewView =  videoPreviewView else {
            print("can't resize preview vide")
            return
        }

        videoPreviewView.frame = self.view.bounds
        videoPreviewView.bindDrawable()
        videoPreviewViewBounds = CGRect.zero
        videoPreviewViewBounds?.size.width = self.view.bounds.width * videoPreviewView.contentScaleFactor
        videoPreviewViewBounds?.size.height = self.view.bounds.height * videoPreviewView.contentScaleFactor
    }

调试显示:

018-12-21-[MTLIOAccelCommandBuffer验证]:错误“使用未提交的编码器提交命令缓冲区”

有人知道要解决此问题吗?

非常感谢

0 个答案:

没有答案