Skip to content

Commit cd12f25

Browse files
JoshuaGrossfacebook-github-bot
authored andcommitted
Change tearDownReactContext ordering to prevent null assertion
Summary: In `tearDownReactContext`, `reactContext.destroy()` sets `mCatalystInstance` to null. We cannot call `reactContext.getCatalystInstance()` after that without hitting an assertion. Change ordering so that doesn't happen in reload or teardown. Changelog: [Internal] Reviewed By: makovkastar Differential Revision: D18041279 fbshipit-source-id: 22658dc506b76cf58aee1008841abacfe9410c9d
1 parent 585dfff commit cd12f25

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,12 @@ private void tearDownReactContext(ReactContext reactContext) {
11261126
}
11271127
}
11281128

1129+
// Remove memory pressure listener before tearing down react context
1130+
// We cannot access the CatalystInstance after destroying the ReactContext.
1131+
mMemoryPressureRouter.removeMemoryPressureListener(reactContext.getCatalystInstance());
1132+
11291133
reactContext.destroy();
11301134
mDevSupportManager.onReactInstanceDestroyed(reactContext);
1131-
mMemoryPressureRouter.removeMemoryPressureListener(reactContext.getCatalystInstance());
11321135
}
11331136

11341137
/** @return instance of {@link ReactContext} configured a {@link CatalystInstance} set */

0 commit comments

Comments
 (0)