Fix error in RCTImageLoader in bridgeless mode

Summary:
Bridgeless mode hasn't been able to load random images. I was able to repro this 100% with base64 images. Loading these images hits a particular flow in `RCTImageLoader` which relies on the bridge to access `RCTNetworking`. This diff uses the TM Lookup Delegate as a fallback.

Changelog: [iOS][Internal] Fix error in RCTImageLoader in bridgeless mode

Reviewed By: sammy-SC

Differential Revision: D19331467

fbshipit-source-id: 8239ee258425da4ed8cb9f6dcdcd7f37c162eb19
This commit is contained in:
Peter Argany
2020-01-13 22:54:16 -08:00
committed by Facebook Github Bot
parent 12f78f145a
commit 442dd26873
+6 -1
View File
@@ -99,6 +99,7 @@ static uint64_t monotonicTimeGetCurrentNanoseconds(void)
@synthesize maxConcurrentLoadingTasks = _maxConcurrentLoadingTasks;
@synthesize maxConcurrentDecodingTasks = _maxConcurrentDecodingTasks;
@synthesize maxConcurrentDecodingBytes = _maxConcurrentDecodingBytes;
@synthesize turboModuleLookupDelegate = _turboModuleLookupDelegate;
RCT_EXPORT_MODULE()
@@ -583,7 +584,8 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
completionBlock:(void (^)(NSError *error, id imageOrData, NSURLResponse *response))completionHandler
{
// Check if networking module is available
if (RCT_DEBUG && ![_bridge respondsToSelector:@selector(networking)]) {
if (RCT_DEBUG && ![_bridge respondsToSelector:@selector(networking)]
&& ![_turboModuleLookupDelegate moduleForName:"RCTNetworking"]) {
RCTLogError(@"No suitable image URL loader found for %@. You may need to "
" import the RCTNetwork library in order to load images.",
request.URL.absoluteString);
@@ -591,6 +593,9 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
}
RCTNetworking *networking = [_bridge networking];
if (!networking) {
networking = [_turboModuleLookupDelegate moduleForName:"RCTNetworking"];
}
// Check if networking module can load image
if (RCT_DEBUG && ![networking canHandleRequest:request]) {