From 5f215cdde2485110b08940f685a8ea31a6327528 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 26 Sep 2023 18:58:56 -0700 Subject: [PATCH] Rename onCatalystInstanceDestroy -> invalidate (#39611) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39611 I'm renaming onCatalystInstanceDestroy -> invalidate, this is necessary to converge TurboModuleRegistry -> turboModuleManager in the next diffs of the stack changelog: [intenral] internal Reviewed By: arushikesarwani94 Differential Revision: D49469208 fbshipit-source-id: 877c5af6ad0fc378ec9cbd952f33db0ea08f761c --- .../com/facebook/react/bridge/CatalystInstanceImpl.java | 2 +- .../src/main/java/com/facebook/react/bridge/JSIModule.java | 2 +- .../java/com/facebook/react/bridge/JSIModuleHolder.java | 2 +- .../java/com/facebook/react/fabric/FabricUIManager.java | 2 +- .../main/java/com/facebook/react/runtime/ReactInstance.java | 4 ++-- .../facebook/react/turbomodule/core/TurboModuleManager.java | 2 +- .../turbomodule/core/interfaces/TurboModuleRegistry.kt | 6 ++++++ .../java/com/facebook/react/uimanager/UIManagerModule.java | 2 +- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java index 2fb5e10a4a7568..b78f11756fe68d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java @@ -370,7 +370,7 @@ public void run() { public void run() { // We need to destroy the TurboModuleManager on the JS Thread if (mTurboModuleManagerJSIModule != null) { - mTurboModuleManagerJSIModule.onCatalystInstanceDestroy(); + mTurboModuleManagerJSIModule.invalidate(); } getReactQueueConfiguration() diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModule.java index 2c0b6301817aaf..64774acc7a4853 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModule.java @@ -18,5 +18,5 @@ public interface JSIModule { void initialize(); /** Called before {CatalystInstance#onHostDestroy} */ - void onCatalystInstanceDestroy(); + void invalidate(); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModuleHolder.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModuleHolder.java index b5bd5902b23587..1ca25d188bede3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModuleHolder.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModuleHolder.java @@ -31,7 +31,7 @@ public JSIModule getJSIModule() { public void notifyJSInstanceDestroy() { if (mModule != null) { - mModule.onCatalystInstanceDestroy(); + mModule.invalidate(); } } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 26bf3a137cdc56..765487f043cdcd 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -411,7 +411,7 @@ public void initialize() { @Override @AnyThread @ThreadConfined(ANY) - public void onCatalystInstanceDestroy() { + public void invalidate() { FLog.i(TAG, "FabricUIManager.onCatalystInstanceDestroy"); if (mDevToolsReactPerfLogger != null) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java index f97db18472926f..408c2656479544 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java @@ -414,8 +414,8 @@ public Collection getNativeModules() { /* package */ void destroy() { FLog.d(TAG, "ReactInstance.destroy() is called."); mQueueConfiguration.destroy(); - mTurboModuleManager.onCatalystInstanceDestroy(); - mFabricUIManager.onCatalystInstanceDestroy(); + mTurboModuleManager.invalidate(); + mFabricUIManager.invalidate(); mHybridData.resetNative(); mComponentNameResolverManager = null; mUIConstantsProviderManager = null; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java index 507fbcfe0b29f1..1d84c76e59a57c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java @@ -423,7 +423,7 @@ private native HybridData initHybrid( public void initialize() {} @Override - public void onCatalystInstanceDestroy() { + public void invalidate() { /* * Halt the production of new TurboModules. * diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.kt index b8201ab66b64e2..45eb8b11ccfdf0 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.kt @@ -34,4 +34,10 @@ interface TurboModuleRegistry { * NativeModules. */ val eagerInitModuleNames: List + + /** + * Called during the turn down process of ReactHost. This method is called before React Native is + * stopped. + */ + fun invalidate() } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 9ff04bc2b07a4f..8ef20ad609a5df 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -195,7 +195,7 @@ public void onHostDestroy() { } @Override - public void onCatalystInstanceDestroy() { + public void invalidate() { super.onCatalystInstanceDestroy(); mEventDispatcher.onCatalystInstanceDestroyed(); mUIImplementation.onCatalystInstanceDestroyed();