Skip to content

Commit a9dd828

Browse files
fkgozalifacebook-github-bot
authored andcommitted
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 #23235 To test: Using react-native init from github, do the steps in #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
1 parent 8da1f11 commit a9dd828

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

React/Base/RCTBridge.m

+2
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ - (void)reload
292292
* Any thread
293293
*/
294294
dispatch_async(dispatch_get_main_queue(), ^{
295+
// WARNING: Invalidation is async, so it may not finish before re-setting up the bridge,
296+
// causing some issues. TODO: revisit this post-Fabric/TurboModule.
295297
[self invalidate];
296298
// Reload is a special case, do not preserve launchOptions and treat reload as a fresh start
297299
self->_launchOptions = nil;

React/CxxBridge/RCTCxxBridge.mm

+3-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,9 @@ - (void)start
357357
dispatch_group_leave(prepareBridge);
358358
} onProgress:^(RCTLoadingProgress *progressData) {
359359
#if RCT_DEV && __has_include("RCTDevLoadingView.h")
360-
RCTDevLoadingView *loadingView = [weakSelf moduleForClass:[RCTDevLoadingView class]];
360+
// Note: RCTDevLoadingView should have been loaded at this point, so no need to allow lazy loading.
361+
RCTDevLoadingView *loadingView = [weakSelf moduleForName:RCTBridgeModuleNameForClass([RCTDevLoadingView class])
362+
lazilyLoadIfNecessary:NO];
361363
[loadingView updateProgress:progressData];
362364
#endif
363365
}];

0 commit comments

Comments
 (0)