Open epoberezkin opened 11 months ago
I just noticed a similar case as well:
Steps to reproduce:
Possible fix:
Remove if captureSession?.isRunning == true {
check from ScannerViewController.swift
's viewDidDisappear
.
Why? Calling self.captureSession?.startRunning()
from setupSession()
hasn't completed yet before we switch to another screen, which results in isRunning
returning false
.
Or better refactor the state management with an enum instead of depending on multiple booleans, something like:
enum CameraSessionState {
case stopped
case requestedToStart(Run?)
case running
case interrupted
}
Thinking about it a bit more, is there a memory leak that's keeping the session? 🤔
Closing the containing sheet does release the camera though.
The trick that works to re-initialise the camera on re-appearance (https://github.com/twostraws/CodeScanner/issues/120) does not help camera to disappear.
Is it something that can be done with or without library change? Maybe expose some method to disable the camera?