mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-15 18:59:54 +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
|
||||
{
|
||||
// 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) {
|
||||
return;
|
||||
}
|
||||
|
||||
ASImageDownloaderProgressImage progress = nil;
|
||||
if (ASInterfaceStateIncludesVisible(self.interfaceState)) {
|
||||
if (ASInterfaceStateIncludesVisible(interfaceState)) {
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
progress = ^(UIImage * _Nonnull progressImage, id _Nullable downloadIdentifier) {
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
|
||||
@ -36,9 +36,9 @@
|
||||
return result.image;
|
||||
}
|
||||
|
||||
- (void)fetchCachedImageWithURL:(NSURL *)URL
|
||||
callbackQueue:(dispatch_queue_t)callbackQueue
|
||||
completion:(void (^)(CGImageRef imageFromCache))completion
|
||||
- (void)cachedImageWithURL:(NSURL *)URL
|
||||
callbackQueue:(dispatch_queue_t)callbackQueue
|
||||
completion:(ASImageCacherCompletion)completion
|
||||
{
|
||||
// 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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user