2

When I restart app from here: https://github.com/zweigraf/face-landmarking-ios picture from camera doesn't appear and printing error: "Ignoring enqueueSampleBuffer because status is failed".

The problem is probably in captureOutput from SessionHandler.swift

1 Answers1

3

I find a solution! Thanks to Why does AVSampleBufferDisplayLayer fail with Operation Interrupted (-11847)?

If you had similar problem you need to set AVSampleBufferDisplayLayer each time app entering foreground. Like this:

//AppDelegate.swift
func applicationWillEnterForeground(_ application: UIApplication) {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.

    viewcontroller?.setLayer()
}


//ViewController.swift
func setLayer() {
    sessionHandler.layer = AVSampleBufferDisplayLayer()
    sessionHandler.layer.frame = preview.bounds
    sessionHandler.layer.videoGravity = AVLayerVideoGravityResizeAspectFill
    preview.layer.addSublayer(sessionHandler.layer)
}

and don't forget to remove sublayer:

func applicationDidEnterBackground(_ application: UIApplication) {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

    viewcontroller?.sessionHandler.layer.removeFromSuperlayer()
}
Community
  • 1
  • 1