Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiding code scanner from view does not release the camera #121

Open
epoberezkin opened this issue Dec 2, 2023 · 1 comment
Open

Hiding code scanner from view does not release the camera #121

epoberezkin opened this issue Dec 2, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@epoberezkin
Copy link

Closing the containing sheet does release the camera though.

The trick that works to re-initialise the camera on re-appearance (#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?

@nathanfallet nathanfallet added the bug Something isn't working label Feb 24, 2024
@dev4justice
Copy link

I just noticed a similar case as well:

Steps to reproduce:

  1. Open a view that has the camera and wait for the camera session to be started
  2. Navigate to another app (slide at the bottom or receive a call)
  3. When you come back to the app, quickly switch to another tab that doesn't have the camera screen
  4. After some time the camera session starts even though the view is no longer visible

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? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants