Ignore PackagerStatusCallback on invalidated ReactInstanceManager (#45458)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45458

Checking for packager is an async operation, which may return when we've already destroyed the ReactInstanceManager. Prevent the CatalystInstance from being created if the ReactInstanceManager has been invalidated.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D59753247

fbshipit-source-id: e3ac2b6dd142330e2d4051519b9863584b33f8a6
This commit is contained in:
Pieter De Baets
2024-07-16 05:19:33 -07:00
committed by Facebook GitHub Bot
parent b243d343fa
commit 5bb57eb2b3
@@ -465,7 +465,6 @@ public class ReactInstanceManager {
if (mUseDeveloperSupport && mJSMainModulePath != null) {
final DeveloperSettings devSettings = mDevSupportManager.getDevSettings();
if (!Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) {
if (mBundleLoader == null) {
mDevSupportManager.handleReloadJS();
@@ -476,6 +475,11 @@ public class ReactInstanceManager {
public void onPackagerStatusFetched(final boolean packagerIsRunning) {
UiThreadUtil.runOnUiThread(
() -> {
// ReactInstanceManager is no longer valid, ignore callback
if (mInstanceManagerInvalidated) {
return;
}
if (packagerIsRunning) {
mDevSupportManager.handleReloadJS();
} else if (mDevSupportManager.hasUpToDateJSBundleInCache()