rorodriguez116 / Camera-SwiftUI

A lightweight camera library for quick integration with SwiftUI - iOS/iPadOS only

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug-001]: Can't take picture after returning from a detail view on NavigationView

moh-abk opened this issue · comments

Great package! - I discovered a bug. When I move to a new view using NavigationLink and then use the back navigationBarButton to return to the camera view - it is no longer possible to take an image; and Couldn't add video device input to the session. is printed in the console.

Thank you! I will review and try to reproduce the error.

Can confirm that this issue is happening for me as well.

I've faced with the same issue

Does anyone have a workaround for this? I have not been able to figure out how to fix or avoid the issue.

Anyone found out how to fix this? It's the same with Apple's AVCam app.

This fixed the problem for me :

  • in CameraService remove self.start() from configureSession()

And :

    func isConfigured() -> Bool {
        return service.isConfigured
    }
    
    func start(){
        service.start()
    }
    func stop(){
        service.stop()
    }
CameraPreview(session: model.session)
                        .onAppear {
                            print("isConfigured = \(model.isConfigured())")
                            if !model.isConfigured() {
                                model.configure()
                            }
                            model.start()
                        }

This issue has been fixed please see this PR.