Don't attempt to load RCTDevLoadingView lazily
Summary: There's a very old issue with reload logic: invalidation and resetting up of the bridge could be racing. In this case, we hit a redbox when: * Chrome debugger is enabled in previous app run, then we launch the app again * The bridge starts, then immediately reloads itself to connect to Chrome * On the 2nd setup, the logic to update the green loading bar, with the % indicator for loading off metro, failed to find the DevLoadingView module instance because the bridge is in the middle of invalidating See https://github.com/facebook/react-native/issues/23235 To test: Using react-native init from github, do the steps in https://github.com/facebook/react-native/issues/23235, no more redbox. Note that the loading indicator % won't be proper still, but at least it doesn't crash/redbox. Reviewed By: JoshuaGross Differential Revision: D14110814 fbshipit-source-id: 835061e50acc6968bffbcc2ddfbe8da79a100df9
This commit is contained in:
Родитель
805e4fe2e0
Коммит
0af31ce77c
|
@ -287,6 +287,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
* Any thread
|
||||
*/
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// WARNING: Invalidation is async, so it may not finish before re-setting up the bridge,
|
||||
// causing some issues. TODO: revisit this post-Fabric/TurboModule.
|
||||
[self invalidate];
|
||||
[self setUp];
|
||||
});
|
||||
|
|
|
@ -357,7 +357,9 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|||
dispatch_group_leave(prepareBridge);
|
||||
} onProgress:^(RCTLoadingProgress *progressData) {
|
||||
#if RCT_DEV && __has_include("RCTDevLoadingView.h")
|
||||
RCTDevLoadingView *loadingView = [weakSelf moduleForClass:[RCTDevLoadingView class]];
|
||||
// Note: RCTDevLoadingView should have been loaded at this point, so no need to allow lazy loading.
|
||||
RCTDevLoadingView *loadingView = [weakSelf moduleForName:RCTBridgeModuleNameForClass([RCTDevLoadingView class])
|
||||
lazilyLoadIfNecessary:NO];
|
||||
[loadingView updateProgress:progressData];
|
||||
#endif
|
||||
}];
|
||||
|
|
Загрузка…
Ссылка в новой задаче