RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks
Solution 1
I was able to workaround the warning by updating
AppDelegate.m#if RCT_DEV
#import <React/RCTDevLoadingView.h>
#endif
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation
moduleProvider:nil
launchOptions:launchOptions];
#if RCT_DEV
[bridge moduleForClass:[RCTDevLoadingView class]];
#endif
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"Test"
initialProperties:nil];
...
}
Solution 2
If you would put a breakpoint on the following line:
RCTLogWarn(@"RCTBridge required dispatch_sync to load %@. This may lead to deadlocks", _moduleClass);
You can see which module/stack is responsible for loading
RCTDevLoadingView in my case it was RCTCxxBridge.mm which was loading the remote bundle and reporting the download progress on RCTDevLoadingView:... onProgress:^(RCTLoadingProgress *progressData) {
#if RCT_DEV && __has_include("RCTDevLoadingView.h")
RCTDevLoadingView *loadingView = [weakSelf moduleForClass:[RCTDevLoadingView class]];
[loadingView updateProgress:progressData];
#endif
}];
Here the RCTCxxBridge is using
moduleForClass which will load an instance of the module if it is not yet available. Due to the queue used for the onProgress block RCTDevLoadingView would be loaded on a non-main queue, while RCTDevLoadingView requires a main-queue setup.
I was able to workaround the warning by optimistically load
RCTDevLoadingView by returning an instance from my RCTBridgeDelegate using:- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge;RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks
ref Link
Comments
Post a Comment