mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Roll out turbo_module_binding_mode experiment
Summary: We ran an experiment to test different implementations of TurboModules HostObjects, as the current one has various inefficiencies, such as re-creating HostFunctions on every property access. The strategy we found to be most efficient and flexible longer-term is to represent the TurboModule with a plain JavaScript object and use a HostObject as its prototype. Whenever a property is accessed through the prototype, we cache the property value on the plain object, so it can be efficiently resolved by the VM for future accesses. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D38355134 fbshipit-source-id: 59253091412d0c6827ad7a4b1ac7dc0c7fe89cc2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9344c7aa5a
commit
1a8ce7a26a
@@ -116,17 +116,6 @@ public class ReactFeatureFlags {
|
||||
/** Feature Flag to control RN Android scrollEventThrottle prop. */
|
||||
public static boolean enableScrollEventThrottle = false;
|
||||
|
||||
/**
|
||||
* Feature flag that controls how turbo modules are exposed to JS
|
||||
*
|
||||
* <ul>
|
||||
* <li>0 = as a HostObject
|
||||
* <li>1 = as a plain object, backed with a HostObject as prototype
|
||||
* <li>2 = as a plain object, with all methods eagerly configured
|
||||
* </ul>
|
||||
*/
|
||||
public static int turboModuleBindingMode = 0;
|
||||
|
||||
/**
|
||||
* Feature Flag to enable View Recycling. When enabled, individual ViewManagers must still opt-in.
|
||||
*/
|
||||
|
||||
+1
-17
@@ -20,17 +20,6 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
constexpr static auto ReactFeatureFlagsJavaDescriptor =
|
||||
"com/facebook/react/config/ReactFeatureFlags";
|
||||
|
||||
static int getFeatureFlagValue(const char *name) {
|
||||
static const auto reactFeatureFlagsJavaDescriptor =
|
||||
jni::findClassStatic(ReactFeatureFlagsJavaDescriptor);
|
||||
const auto field =
|
||||
reactFeatureFlagsJavaDescriptor->getStaticField<jint>(name);
|
||||
return reactFeatureFlagsJavaDescriptor->getStaticFieldValue(field);
|
||||
}
|
||||
|
||||
TurboModuleManager::TurboModuleManager(
|
||||
jni::alias_ref<TurboModuleManager::javaobject> jThis,
|
||||
RuntimeExecutor runtimeExecutor,
|
||||
@@ -180,13 +169,8 @@ void TurboModuleManager::installJSIBindings() {
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
TurboModuleBindingMode bindingMode = static_cast<TurboModuleBindingMode>(
|
||||
getFeatureFlagValue("turboModuleBindingMode"));
|
||||
TurboModuleBinding::install(
|
||||
runtime,
|
||||
std::move(turboModuleProvider),
|
||||
bindingMode,
|
||||
longLivedObjectCollection_);
|
||||
runtime, std::move(turboModuleProvider), longLivedObjectCollection_);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user