Skip to content

Commit 283a9dc

Browse files
Eric Williamsonfacebook-github-bot
authored andcommitted
Revert D16553363: [RN][TurboModule] Make TurboModules long-lived on Android
Differential Revision: D16553363 Original commit changeset: c95e150d6967 fbshipit-source-id: d035724ce131b560abc70e94410d727951a83241
1 parent 5263660 commit 283a9dc

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,20 @@ void TurboModuleManager::installJSIBindings() {
5656
}
5757
TurboModuleBinding::install(*runtime_, std::make_shared<TurboModuleBinding>(
5858
[this](const std::string &name) -> std::shared_ptr<TurboModule> {
59-
auto turboModuleLookup = turboModuleCache_.find(name);
60-
if (turboModuleLookup != turboModuleCache_.end()) {
61-
return turboModuleLookup->second;
62-
}
63-
6459
auto cxxModule = turboModuleManagerDelegate_->cthis()->getTurboModule(name, jsCallInvoker_);
6560
if (cxxModule) {
66-
turboModuleCache_.insert({name, cxxModule});
6761
return cxxModule;
6862
}
6963

7064
auto legacyCxxModule = getLegacyCxxJavaModule(name);
7165
if (legacyCxxModule) {
72-
auto turboModule = std::make_shared<react::TurboCxxModule>(legacyCxxModule->cthis()->getModule(), jsCallInvoker_);
73-
turboModuleCache_.insert({name, turboModule});
74-
return turboModule;
66+
return std::make_shared<react::TurboCxxModule>(legacyCxxModule->cthis()->getModule(), jsCallInvoker_);
7567
}
7668

7769
auto moduleInstance = getJavaModule(name);
7870

7971
if (moduleInstance) {
80-
auto turboModule = turboModuleManagerDelegate_->cthis()->getTurboModule(name, moduleInstance, jsCallInvoker_);
81-
turboModuleCache_.insert({name, turboModule});
82-
return turboModule;
72+
return turboModuleManagerDelegate_->cthis()->getTurboModule(name, moduleInstance, jsCallInvoker_);
8373
}
8474

8575
return std::shared_ptr<TurboModule>(nullptr);

ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#pragma once
99

1010
#include <memory>
11-
#include <unordered_map>
1211
#include <fb/fbjni.h>
1312
#include <jsi/jsi.h>
1413
#include <ReactCommon/TurboModule.h>
@@ -38,14 +37,6 @@ class TurboModuleManager : public jni::HybridClass<TurboModuleManager> {
3837
std::shared_ptr<JSCallInvoker> jsCallInvoker_;
3938
jni::global_ref<TurboModuleManagerDelegate::javaobject> turboModuleManagerDelegate_;
4039

41-
/**
42-
* TODO(T48018690):
43-
* All modules are currently long-lived.
44-
* We need to come up with a mechanism to allow modules to specify whether
45-
* they want to be long-lived or short-lived.
46-
*/
47-
std::unordered_map<std::string, std::shared_ptr<react::TurboModule>> turboModuleCache_;
48-
4940
jni::global_ref<JTurboModule> getJavaModule(std::string name);
5041
jni::global_ref<CxxModuleWrapper::javaobject> getLegacyCxxJavaModule(std::string name);
5142
void installJSIBindings();

ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ @implementation RCTTurboModuleManager {
4040
__weak id<RCTTurboModuleManagerDelegate> _delegate;
4141
__weak RCTBridge *_bridge;
4242
/**
43-
* TODO(T48018690):
43+
* TODO(rsnara):
4444
* All modules are currently long-lived.
4545
* We need to come up with a mechanism to allow modules to specify whether
4646
* they want to be long-lived or short-lived.

0 commit comments

Comments
 (0)