-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move initialization of PHPhotoLibrary and PHCachingImageManager to background #565
Conversation
… to avoid possible freezes
|
||
DispatchQueue.main.async(execute: { [weak self] in | ||
guard let self = self else { | ||
DispatchQueue.main.async(execute: completion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already executing on the main queue, right?
@@ -113,7 +133,7 @@ final class PhotosInputDataProvider: NSObject, PhotosInputDataProviderProtocol, | |||
request.handleCompletion(with: result) | |||
} | |||
request.cancelBlock = { [weak self] in | |||
self?.imageManager.cancelImageRequest(requestId) | |||
self?.imageManager?.cancelImageRequest(requestId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the image manager be captured by this closure instead of self?
Codecov Report
@@ Coverage Diff @@
## master #565 +/- ##
==========================================
- Coverage 59.97% 59.61% -0.37%
==========================================
Files 87 87
Lines 3945 3969 +24
==========================================
Hits 2366 2366
- Misses 1579 1603 +24
Continue to review full report at Codecov.
|
sSelf.collectionView.reloadData() | ||
DispatchQueue.main.async(execute: completion) | ||
sSelf.collectionViewQueue.addTask { [weak self] (completion) in | ||
guard let sSelf = self else { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should a completion be called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't before, I decided not to change it
Closed as duplicate of #566 |
We have freezes (not deadlocks) inside PHCachingImageManager initialization. According to stach trace, it might be related to PHPhotoLibrary singleton initialization. So it was moved to background thread to avoid blocking UI.