Describe the bug
Video halts on iPhone 8 / iOS currently latest 13.6.1 all the time
on iPhone X / iOS currently latest 13.6.1 about 10% of times
To Reproduce
Steps to reproduce the behavior:
Just go to Video page
Screenshots
https://www.dropbox.com/s/1qosruev2xygilx/2020-08-28%2021.36.52.png?dl=0
Environment (please complete the following information):
iPhone 8 / iOS currently latest 13.6.1 all the time
on iPhone X / iOS currently latest 13.6.1 about 10% of times
Installation Type
Cocoapods
Photo works ok, video on iPhone 8 just shows black square. Record button gets enabled in a second, but nothing changes. Switching to front camera has no effect. Clicking the Record button has no effect, the timer doesn't even start. It may start to work after several attempts (changing to Photo and back to Video).
iPad 2 (or something, some old one) with iOS 12 - video halts. iPhone X - problem 10% of times, may be even less. iPhone 11 Pro - works perfectly. Seems to be a problem for slower devices.
The problem is here
public func stopCamera() {
if session.isRunning {
sessionQueue.async { [weak self] in
self?.session.stopRunning()
}
}
}
session stops in async mode, so may be when video session starts after photo session and photo session is not finished yet, then video session doesn't start the normal way.
Problem does no exist when switching from gallery to video, because there were no session, only when switching from photo to video.
I don't know if there's any real reason to make it async. So simple fix can be removing async. But better fix will be making some global semaphore and starting / stopping session async way with semaphore.
This needs attention + 1
@nickeyzzz Thank you so much for the details and the potential fix 馃憤 . Could you please try a test project with Carthage or SPM (spm branch), to see if the problem package manager-related (which would be weird).
That would really help :)
Absolutely not. It has the same behaviour in your test app, so it's not related to a package manager in any way. Please take a look at my fix. It's related to procedures Start/StopCamera that do act at the same moment when you change photo-video. That must be semaphored.