Comments (12)
PR here : #26
I'll take time tomorrow to issue a new version with the fix :)
from ypimagepicker.
https://github.com/Yummypets/YPImagePicker/releases/tag/2.5.1
:)
from ypimagepicker.
@viktorgardart,
First thanks a ton for taking the time to open an issue for this.
I had the issue before on and off, on my side the issue was quite hard to reproduce, it seemed to happen more often in release configuration.
I came to the conclusion that this was thread related, something like a data race for instance.
This would explain the freeze and the randomness of the issue.
This is quite annoying :/
I'm going to look into it again but if you want to instrument as well I could definitely use some help :) We'll report our findings here .
Cheers,
from ypimagepicker.
@viktorgardart oO i'Ve found :) thanks so much for bringing this up I had gave up earlier :)
from ypimagepicker.
will post the fix
from ypimagepicker.
diff --git a/Source/Camera/YPCameraVC.swift b/Source/Camera/YPCameraVC.swift
index 2c82c30..8ee1238 100644
--- a/Source/Camera/YPCameraVC.swift
+++ b/Source/Camera/YPCameraVC.swift
@@ -13,7 +13,7 @@ import Photos
public class YPCameraVC: UIViewController, UIGestureRecognizerDelegate, PermissionCheckable {
public var didCapturePhoto: ((UIImage) -> Void)?
- private let sessionQueue = DispatchQueue(label: "YPCameraVCSerialQueue")
+ private let sessionQueue = DispatchQueue(label: "YPCameraVCSerialQueue", qos: .background)
let session = AVCaptureSession()
var device: AVCaptureDevice? {
return videoInput?.device
@@ -49,21 +49,27 @@ public class YPCameraVC: UIViewController, UIGestureRecognizerDelegate, Permissi
public override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
+ refreshFlashButton()
+ }
+
+ func tryToSetupPreview() {
if !isPreviewSetup {
setupPreview()
isPreviewSetup = true
}
- refreshFlashButton()
}
func setupPreview() {
let videoLayer = AVCaptureVideoPreviewLayer(session: session)
- videoLayer.frame = v.previewViewContainer.bounds
- videoLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
- v.previewViewContainer.layer.addSublayer(videoLayer)
- let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(focusTapped(_:)))
- tapRecognizer.delegate = self
- v.previewViewContainer.addGestureRecognizer(tapRecognizer)
+
+ DispatchQueue.main.async {
+ videoLayer.frame = self.v.previewViewContainer.bounds
+ videoLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
+ self.v.previewViewContainer.layer.addSublayer(videoLayer)
+ let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.focusTapped(_:)))
+ tapRecognizer.delegate = self
+ self.v.previewViewContainer.addGestureRecognizer(tapRecognizer)
+ }
}
private func setupCaptureSession() {
@@ -120,6 +126,7 @@ public class YPCameraVC: UIViewController, UIGestureRecognizerDelegate, Permissi
self.session.stopRunning()
case .authorized:
self.session.startRunning()
+ self.tryToSetupPreview()
}
}
}
from ypimagepicker.
Something that is very strange though concerning the dispatchQueue
DispatchQueue(label: "YPCameraVCSerialQueue") // SLOW
DispatchQueue(label: "YPCameraVCSerialQueue", qos: .userInitiated) // SLOW
DispatchQueue(label: "YPCameraVCSerialQueue", qos: .userInteractive) // SLOW
DispatchQueue(label: "YPCameraVCSerialQueue", qos: .utility) // SLOW
DispatchQueue(label: "YPCameraVCSerialQueue", qos: .default) // SLOW
DispatchQueue(label: "YPCameraVCSerialQueue", qos: .background) // FAST
From what I believed, userInteractive
should've been the fastest but somehow that's not the case :/
The second part of the fix is doing let videoLayer = AVCaptureVideoPreviewLayer(session: session)
in the session queue.
from ypimagepicker.
Thanks a lot for the quick reply, I’ll check out the fix later today/tomorrow! 🙂
Sent with GitHawk
from ypimagepicker.
Works! 💃 Thanks @s4cha
from ypimagepicker.
Or.. hmm 🤔
It went from always being slow to being slow sometimes. 😕
from ypimagepicker.
mm that's V weird :/ not happening anymore on my side what device are you testing on?
from ypimagepicker.
The same device as previously, but haven't seen it since.. Closing for now and reopening if I find anything new!
from ypimagepicker.
Related Issues (20)
- Cannot support Carthage HOT 2
- showsCrop doesn't work with multiple selection HOT 1
- Use volume up / volume down buttons to shoot a picture
- onlySquare does not crop images to square HOT 4
- If you're trying to override traits, you must use the appropriate API.
- App crashes or freezes when selecting multiple videos HOT 1
- photo from camera can not find the PHAssets HOT 3
- App Freez
- feat: new yml forms for issues HOT 1
- Video size issue selecting from gallery
- Stored properties cannot be marked unavailable with '@available' HOT 12
- Invalid zoom in/out
- Does not compile with XCode 15.0 Beta 2 (13 errors) HOT 2
- Inquiry about adding silent camera support
- Stored properties cannot be marked unavailable with '@available' HOT 8
- Customise buttons actions
- YPAlbumsManager.fetchAlbums() is too slow for users with many albums
- `UIScreen.main` will be deprecated in a future version of iOS
- Picking a video messes with video_full_range_flag
- Xcode 15 beta - Stored properties cannot be marked unavailable with '@available' HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ypimagepicker.