Skip to content

Commit

Permalink
fix: Calculating camera frame size on viewWillAppear instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ruisebas committed Jul 5, 2024
1 parent 737eb08 commit 46ab0a4
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ final class _LivenessViewController: UIViewController {
super.viewDidLoad()
view.backgroundColor = .black
layoutSubviews()
}

override func viewWillAppear(_ animated: Bool) {
setupAVLayer()

This comment has been minimized.

Copy link
@phantumcode

phantumcode Jul 5, 2024

Contributor

calling setupAVLayer() in viewWillAppear can be problematic here as it will result in the camera being reconfigured multiple times, resulting in AVCaptureSession being destroyed and recreated. This can potentially reintroduce the difficult to reproduce crash in AVCaptureSession [AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration

This comment has been minimized.

Copy link
@ruisebas

ruisebas Jul 5, 2024

Author Member

My understanding is that the camera will only be configured once, since there's a condition at the top of the setupAVLayer():

guard previewLayer == nil else { return }

(ref)

But I'll manually validate it next week just in case

super.viewWillAppear(animated)
}

private func layoutSubviews() {
Expand Down

0 comments on commit 46ab0a4

Please sign in to comment.