11

Here is my code setting up a simple camera app

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    let deviceSession = AVCaptureDeviceDiscoverySession(deviceTypes: [.builtInDualCamera, .builtInTelephotoCamera, .builtInWideAngleCamera], mediaType: AVMediaTypeVideo, position: .unspecified)
    for device in (deviceSession?.devices)!{
        if device.position == AVCaptureDevicePosition.front {
            do {
                currentDevice = device
                let input = try AVCaptureDeviceInput(device: device)
                if captureSession.canAddInput(input){
                    captureSession.addInput(input)

                    if captureSession.canAddOutput(photoOutput){
                        captureSession.addOutput(photoOutput)
                    }

                    if captureSession.canAddOutput(videoOutput){
                        captureSession.addOutput(videoOutput)
                        videoOutput.connection(withMediaType: AVMediaTypeVideo).isVideoMirrored = true
                    }

                    previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
                    previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
                    previewLayer.connection.videoOrientation = .portrait //Change orientation

                    cameraView.layer.addSublayer(previewLayer)
                    cameraView.addSubview(takePictureButton)
                    cameraView.addSubview(takeVideoButton)
                    cameraView.addSubview(saveVideoButton)


                    previewLayer.position = CGPoint(x: self.view.center.x, y: self.view.center.y)
                    previewLayer.bounds = CGRect(x: 100, y: 150, width: self.view.frame.width, height: self.view.frame.height)

                }

                captureSession.startRunning()
            } catch let avError {
                print(avError)
            }
        }
    }
}

This works fine, but throws this message in the debug window

2018-02-26 20:12:27.699481-0800 FACS[1063:425226] [] <<<<     
AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>>  
-[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl    
outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device 
discovery mode to DiscoveryMode_None (client: FACS)
2018-02-26 20:12:27.774719-0800 FACS[1063:425226] [framework]
CUICatalog: Invalid asset name supplied: '(null)'

The strange part is that when I try to clean up the code above, it still works but now is much slower (by cleanup I mean put things in helper functions). By looking at related posts,

Playing audio from URL give me this log error and stuck .(Swift)

AVPlayer is not playing in iOS 11

the only thing I can deduce is that it has something related to IOS 11. How do I fix this error?

Aditya Garg
  • 838
  • 6
  • 19
  • Did you ever find a solution to this ? I have the same issue, video does not play for me at times when I get the console message: AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_Presence (client: ABCD) – Curious101 May 01 '18 at 02:18
  • No, problem just disappeared on its own – Aditya Garg May 01 '18 at 02:26
  • I'm facing same error. it's making my app slow. After camera I'm presenting audio view controller. which took 2-8 sec delay for presenting. it only happen after capturing multiple images. Not sure how to fix it. – jay patel Jun 18 '18 at 05:06
  • Hello , i am facing same error did you find any solution here ? If yes will you please share us the same so that it helps us? – Anita Nagori Nov 19 '18 at 05:28
  • No, the problem just disappeared on its own. – Aditya Garg Dec 17 '18 at 20:29

0 Answers0