Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5eafcf7

Browse files
fkgozaligrabbou
authored andcommittedFeb 18, 2019
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 facebook#23235 To test: Using react-native init from github, do the steps in facebook#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 fc41e1c commit 5eafcf7

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
@@ -287,6 +287,8 @@ - (void)reload
287287
* Any thread
288288
*/
289289
dispatch_async(dispatch_get_main_queue(), ^{
290+
// WARNING: Invalidation is async, so it may not finish before re-setting up the bridge,
291+
// causing some issues. TODO: revisit this post-Fabric/TurboModule.
290292
[self invalidate];
291293
[self setUp];
292294
});

‎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)
Please sign in to comment.