mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-18 20:30:51 +00:00
[ASMultiplexImageNode] Avoid deadlock by reading our interface state earlier
This commit is contained in:
parent
0022cad000
commit
7128f69678
@ -456,12 +456,16 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
|||||||
|
|
||||||
- (void)_updateProgressImageBlockOnDownloaderIfNeeded
|
- (void)_updateProgressImageBlockOnDownloaderIfNeeded
|
||||||
{
|
{
|
||||||
|
// Read our interface state so that we don't lock super while holding our lock.
|
||||||
|
ASInterfaceState interfaceState = self.interfaceState;
|
||||||
|
ASDN::MutexLocker l(_downloadIdentifierLock);
|
||||||
|
|
||||||
if (!_downloaderImplementsSetProgress || _downloadIdentifier == nil) {
|
if (!_downloaderImplementsSetProgress || _downloadIdentifier == nil) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASImageDownloaderProgressImage progress = nil;
|
ASImageDownloaderProgressImage progress = nil;
|
||||||
if (ASInterfaceStateIncludesVisible(self.interfaceState)) {
|
if (ASInterfaceStateIncludesVisible(interfaceState)) {
|
||||||
__weak __typeof__(self) weakSelf = self;
|
__weak __typeof__(self) weakSelf = self;
|
||||||
progress = ^(UIImage * _Nonnull progressImage, id _Nullable downloadIdentifier) {
|
progress = ^(UIImage * _Nonnull progressImage, id _Nullable downloadIdentifier) {
|
||||||
__typeof__(self) strongSelf = weakSelf;
|
__typeof__(self) strongSelf = weakSelf;
|
||||||
|
|||||||
@ -36,9 +36,9 @@
|
|||||||
return result.image;
|
return result.image;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)fetchCachedImageWithURL:(NSURL *)URL
|
- (void)cachedImageWithURL:(NSURL *)URL
|
||||||
callbackQueue:(dispatch_queue_t)callbackQueue
|
callbackQueue:(dispatch_queue_t)callbackQueue
|
||||||
completion:(void (^)(CGImageRef imageFromCache))completion
|
completion:(ASImageCacherCompletion)completion
|
||||||
{
|
{
|
||||||
// We do not check the cache here and instead check it in downloadImageWithURL to avoid checking the cache twice.
|
// We do not check the cache here and instead check it in downloadImageWithURL to avoid checking the cache twice.
|
||||||
// If we're targeting the main queue and we're on the main thread, complete immediately.
|
// If we're targeting the main queue and we're on the main thread, complete immediately.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user