[AS*ImageNode] dispatch to the background before scheduling image download request (perf).

This commit is contained in:
Scott Goodson
2016-02-20 13:01:03 -08:00
parent cd6ca2885e
commit ca8357a364
2 changed files with 66 additions and 59 deletions

View File

@@ -21,6 +21,7 @@
#import "ASLog.h"
#import "ASPhotosFrameworkImageRequest.h"
#import "ASEqualityHelpers.h"
#import "ASInternalHelpers.h"
#if !AS_IOS8_SDK_OR_LATER
#error ASMultiplexImageNode can be used on iOS 7, but must be linked against the iOS 8 SDK.
@@ -751,6 +752,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
}
// Download!
ASPerformBlockOnBackgroundThread(^{
if (_downloaderSupportsNewProtocol) {
[self _setDownloadIdentifier:[_downloader downloadImageWithURL:imageURL
callbackQueue:dispatch_get_main_queue()
@@ -791,6 +793,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
[strongSelf->_delegate multiplexImageNode:weakSelf didFinishDownloadingImageWithIdentifier:imageIdentifier error:error];
}]];
}
});
}
#pragma mark -

View File

@@ -13,6 +13,7 @@
#import "ASDisplayNode+FrameworkPrivate.h"
#import "ASEqualityHelpers.h"
#import "ASThread.h"
#import "ASInternalHelpers.h"
#if PIN_REMOTE_IMAGE
#import "ASPINRemoteImageDownloader.h"
@@ -263,6 +264,8 @@
- (void)_downloadImageWithCompletion:(void (^)(UIImage *image, NSError*, id downloadIdentifier))finished
{
ASPerformBlockOnBackgroundThread(^{
ASDN::MutexLocker l(_lock);
if (_downloaderSupportsNewProtocol) {
_downloadIdentifier = [_downloader downloadImageWithURL:_URL
callbackQueue:dispatch_get_main_queue()
@@ -282,6 +285,7 @@
}
}];
}
});
}
- (void)_lazilyLoadImageIfNecessary