Awalz / SwiftyCam

A Snapchat Inspired iOS Camera Framework written in Swift
BSD 2-Clause "Simplified" License
2.08k stars 326 forks source link

Short delay when closing camera/switching views #185

Open Bramnouwen opened 6 years ago

Bramnouwen commented 6 years ago

There's a small delay when I'm closing the camera which can be seen here: https://imgur.com/a/BDGeFOK

After I dismiss the view you can see a small line at the bottom of the screen which disappears after a short delay and I don't know why this is happening.

This also happens when switching tabs if the camera view is shown as a tab instead of a modal screen.

Has anyone else encountered this problem?

ljs19923 commented 5 years ago

@Bramnouwen same problem ! Did you find a solution ?

Bramnouwen commented 5 years ago

Kind of, someone suggested dispatching the closing of the camera to the global/background thread, that made it faster but not 100% perfect

I'm going to be be implementing a camera myself now though as this seems to be abandoned and I don't need a too complicated camera anyway.

Good luck!

ljs19923 commented 5 years ago

The closing or the opening ? Because for me its the opening who is longer..

Bramnouwen commented 5 years ago

Well, as the issue suggests, for me it was the closing of the camera :-)

Putting the closing of the camera in the following code worked for me, but I've now switched to coding the camera myself:

DispatchQueue.global(qos: .default).async {
     //closing of camera here
}

Have you tried that? The opening of the camera worked perfectly for me so I didn't use it for that, but it's worth a shot.

ljs19923 commented 5 years ago

Thanks @Bramnouwen i will try that. And your custom camera is not open source ? :)

Bramnouwen commented 5 years ago

It's nothing complicated haha, I just need to be able to record video with the back camera and be able to save it to the gallery, you can google tutorials that use AVFoundation to build a camera.

Here are some SO links I used to help: