Skip to content

Commit

Permalink
Reset ReactInstanceManager state on failure to allow retries (#32901)
Browse files Browse the repository at this point in the history
Summary:
This fixes #32898 by reseting ReactInstanceManager state when `createReactContext` throws. By resetting the state, we allow future attempts at creating the React context.

## Changelog

[Android] [Fixed] - Fixed empty screen after retrying a BundleDownloader failure in dev mode

Pull Request resolved: #32901

Test Plan: Go through the steps to reproduce listed in #32898 and see that the React Native application starts.

Reviewed By: cortinico

Differential Revision: D33634178

Pulled By: ShikaSD

fbshipit-source-id: e54d12d5f33c9c7c0ca213113871b88c2f1dc261
  • Loading branch information
samkline authored and facebook-github-bot committed Jan 19, 2022
1 parent 3addafa commit c8d823b
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1103,14 +1103,22 @@ public void run() {
// create
mHasStartedCreatingInitialContext = true;

final ReactApplicationContext reactApplicationContext;
try {
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
ReactMarker.logMarker(VM_INIT);
final ReactApplicationContext reactApplicationContext =
reactApplicationContext =
createReactContext(
initParams.getJsExecutorFactory().create(),
initParams.getJsBundleLoader());

} catch (Exception e) {
// Reset state and bail out. This lets us try again later.
mHasStartedCreatingInitialContext = false;
mCreateReactContextThread = null;
mDevSupportManager.handleException(e);
return;
}
try {
mCreateReactContextThread = null;
ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
final Runnable maybeRecreateReactContextRunnable =
Expand Down

0 comments on commit c8d823b

Please sign in to comment.