mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-26 10:45:32 +08:00
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:
committed by
Facebook Github Bot
parent
8da1f1149f
commit
a9dd828c68
@@ -292,6 +292,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];
|
||||
// Reload is a special case, do not preserve launchOptions and treat reload as a fresh start
|
||||
self->_launchOptions = nil;
|
||||
|
||||
@@ -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
|
||||
}];
|
||||
|
||||
Reference in New Issue
Block a user