Remove redundant queue switch from RCTLocalAssetImageLoader

Summary:
Switching queues in `RCTLocalAssetImageLoader` is unnecessary. We dispatch to main queue before assigning the image to `UIImageView`.

Changelog: Remove redundant queue switch from RCTLocalAssetImageLoader

Reviewed By: PeteTheHeat

Differential Revision: D20347223

fbshipit-source-id: ff6215838f0462356d4a516e6ec31c82a742881a
This commit is contained in:
Samuel Susla 2020-03-11 13:57:52 -07:00 коммит произвёл Facebook GitHub Bot
Родитель f3a53fd338
Коммит 3198009410
1 изменённых файлов: 12 добавлений и 21 удалений

Просмотреть файл

@ -49,28 +49,19 @@ RCT_EXPORT_MODULE()
partialLoadHandler:(RCTImageLoaderPartialLoadBlock)partialLoadHandler partialLoadHandler:(RCTImageLoaderPartialLoadBlock)partialLoadHandler
completionHandler:(RCTImageLoaderCompletionBlock)completionHandler completionHandler:(RCTImageLoaderCompletionBlock)completionHandler
{ {
__block auto cancelled = std::make_shared<std::atomic<bool>>(false); UIImage *image = RCTImageFromLocalAssetURL(imageURL);
RCTExecuteOnMainQueue(^{ if (image) {
if (cancelled->load()) { if (progressHandler) {
return; progressHandler(1, 1);
} }
completionHandler(nil, image);
UIImage *image = RCTImageFromLocalAssetURL(imageURL); } else {
if (image) { NSString *message = [NSString stringWithFormat:@"Could not find image %@", imageURL];
if (progressHandler) { RCTLogWarn(@"%@", message);
progressHandler(1, 1); completionHandler(RCTErrorWithMessage(message), nil);
} }
completionHandler(nil, image);
} else { return nil;
NSString *message = [NSString stringWithFormat:@"Could not find image %@", imageURL];
RCTLogWarn(@"%@", message);
completionHandler(RCTErrorWithMessage(message), nil);
}
});
return ^{
cancelled->store(true);
};
} }
@end @end