Skip to content
Browse files

Don't attempt to load RCTDevLoadingView lazily

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
  • Loading branch information...
fkgozali authored and grabbou committed Feb 15, 2019
1 parent 1768655 commit 2f33b50f4fea4c11724801761a9769660eb383b9
Showing with 5 additions and 1 deletion.
  1. +2 −0 React/Base/RCTBridge.m
  2. +3 −1 React/CxxBridge/
@@ -292,6 +292,8 @@ - (void)reload
* 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 @@ - (void)start
} 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])
[loadingView updateProgress:progressData];

0 comments on commit 2f33b50

Please sign in to comment.
You can’t perform that action at this time.