Skip to content

Commit

Permalink
delete state alignment mechanism (facebook#46658)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#46658

We are shipping a better solution: Runtime Shadow Node Reference Syncing which is being rolled out.

Differential Revision: D63456344
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Sep 28, 2024
1 parent 513e966 commit b70f675
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 407 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<bce0548a9e58299746c75aad95a25275>>
* @generated SignedSource<<32afa527b04c5ede00ecbac498d229e9>>
*/

/**
Expand Down Expand Up @@ -334,12 +334,6 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun useRuntimeShadowNodeReferenceUpdateOnLayout(): Boolean = accessor.useRuntimeShadowNodeReferenceUpdateOnLayout()

/**
* When enabled, it uses optimised state reconciliation algorithm.
*/
@JvmStatic
public fun useStateAlignmentMechanism(): Boolean = accessor.useStateAlignmentMechanism()

/**
* In Bridgeless mode, should legacy NativeModules use the TurboModule system?
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<19dca512d93d689e927ee5988a43e646>>
* @generated SignedSource<<8b904803bc7fea167a54395830a0a9dd>>
*/

/**
Expand Down Expand Up @@ -71,7 +71,6 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
private var useRuntimeShadowNodeReferenceUpdateCache: Boolean? = null
private var useRuntimeShadowNodeReferenceUpdateOnLayoutCache: Boolean? = null
private var useStateAlignmentMechanismCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null

Expand Down Expand Up @@ -534,15 +533,6 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

override fun useStateAlignmentMechanism(): Boolean {
var cached = useStateAlignmentMechanismCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.useStateAlignmentMechanism()
useStateAlignmentMechanismCache = cached
}
return cached
}

override fun useTurboModuleInterop(): Boolean {
var cached = useTurboModuleInteropCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<76eebf045692e945d39a4ea27a63ae02>>
* @generated SignedSource<<03027b2e7b5861322553d638ff9890f8>>
*/

/**
Expand Down Expand Up @@ -130,8 +130,6 @@ public object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic public external fun useRuntimeShadowNodeReferenceUpdateOnLayout(): Boolean

@DoNotStrip @JvmStatic public external fun useStateAlignmentMechanism(): Boolean

@DoNotStrip @JvmStatic public external fun useTurboModuleInterop(): Boolean

@DoNotStrip @JvmStatic public external fun useTurboModules(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<8155a9c1309145fefdb19feb33c241db>>
* @generated SignedSource<<8744b271838b0d6c5e6234880bdfd360>>
*/

/**
Expand Down Expand Up @@ -125,8 +125,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun useRuntimeShadowNodeReferenceUpdateOnLayout(): Boolean = false

override fun useStateAlignmentMechanism(): Boolean = false

override fun useTurboModuleInterop(): Boolean = false

override fun useTurboModules(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<5e4e474b62996caec15bbf8af9622a0a>>
* @generated SignedSource<<f834dd3f01623acbb34f9f359c383f5d>>
*/

/**
Expand Down Expand Up @@ -75,7 +75,6 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
private var useRuntimeShadowNodeReferenceUpdateCache: Boolean? = null
private var useRuntimeShadowNodeReferenceUpdateOnLayoutCache: Boolean? = null
private var useStateAlignmentMechanismCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null

Expand Down Expand Up @@ -589,16 +588,6 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

override fun useStateAlignmentMechanism(): Boolean {
var cached = useStateAlignmentMechanismCache
if (cached == null) {
cached = currentProvider.useStateAlignmentMechanism()
accessedFeatureFlags.add("useStateAlignmentMechanism")
useStateAlignmentMechanismCache = cached
}
return cached
}

override fun useTurboModuleInterop(): Boolean {
var cached = useTurboModuleInteropCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<97eddbbd75ff7cfd0f1c905d72e9eafd>>
* @generated SignedSource<<12ca99bd2947eda279018830e2f5f795>>
*/

/**
Expand Down Expand Up @@ -125,8 +125,6 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun useRuntimeShadowNodeReferenceUpdateOnLayout(): Boolean

@DoNotStrip public fun useStateAlignmentMechanism(): Boolean

@DoNotStrip public fun useTurboModuleInterop(): Boolean

@DoNotStrip public fun useTurboModules(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<383e9749c506bc2326455ef907e06a4c>>
* @generated SignedSource<<5b012254d44fdf27d76dd656a2e37a48>>
*/

/**
Expand Down Expand Up @@ -345,12 +345,6 @@ class ReactNativeFeatureFlagsProviderHolder
return method(javaProvider_);
}

bool useStateAlignmentMechanism() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useStateAlignmentMechanism");
return method(javaProvider_);
}

bool useTurboModuleInterop() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useTurboModuleInterop");
Expand Down Expand Up @@ -622,11 +616,6 @@ bool JReactNativeFeatureFlagsCxxInterop::useRuntimeShadowNodeReferenceUpdateOnLa
return ReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdateOnLayout();
}

bool JReactNativeFeatureFlagsCxxInterop::useStateAlignmentMechanism(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::useStateAlignmentMechanism();
}

bool JReactNativeFeatureFlagsCxxInterop::useTurboModuleInterop(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::useTurboModuleInterop();
Expand Down Expand Up @@ -807,9 +796,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"useRuntimeShadowNodeReferenceUpdateOnLayout",
JReactNativeFeatureFlagsCxxInterop::useRuntimeShadowNodeReferenceUpdateOnLayout),
makeNativeMethod(
"useStateAlignmentMechanism",
JReactNativeFeatureFlagsCxxInterop::useStateAlignmentMechanism),
makeNativeMethod(
"useTurboModuleInterop",
JReactNativeFeatureFlagsCxxInterop::useTurboModuleInterop),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<293ed423f770e7e0ba95b19eb5c28dc2>>
* @generated SignedSource<<7828e8c5267a3ffce342a150c05e3d81>>
*/

/**
Expand Down Expand Up @@ -183,9 +183,6 @@ class JReactNativeFeatureFlagsCxxInterop
static bool useRuntimeShadowNodeReferenceUpdateOnLayout(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool useStateAlignmentMechanism(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool useTurboModuleInterop(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<85cdb5a41317e9671cc23b2c7345c04d>>
* @generated SignedSource<<e033ef0aefc622c1603799031a1c06ae>>
*/

/**
Expand Down Expand Up @@ -225,10 +225,6 @@ bool ReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdateOnLayout() {
return getAccessor().useRuntimeShadowNodeReferenceUpdateOnLayout();
}

bool ReactNativeFeatureFlags::useStateAlignmentMechanism() {
return getAccessor().useStateAlignmentMechanism();
}

bool ReactNativeFeatureFlags::useTurboModuleInterop() {
return getAccessor().useTurboModuleInterop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<ea2c2d19e83630b549e719057cd1982e>>
* @generated SignedSource<<59bef17cdec5857e9327e8f04f7e0204>>
*/

/**
Expand Down Expand Up @@ -292,11 +292,6 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool useRuntimeShadowNodeReferenceUpdateOnLayout();

/**
* When enabled, it uses optimised state reconciliation algorithm.
*/
RN_EXPORT static bool useStateAlignmentMechanism();

/**
* In Bridgeless mode, should legacy NativeModules use the TurboModule system?
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<daeeaa9fbbc3f9eb9d1b4164f6e8c954>>
* @generated SignedSource<<71d845d565e2a8783f7583213e6010de>>
*/

/**
Expand Down Expand Up @@ -947,24 +947,6 @@ bool ReactNativeFeatureFlagsAccessor::useRuntimeShadowNodeReferenceUpdateOnLayou
return flagValue.value();
}

bool ReactNativeFeatureFlagsAccessor::useStateAlignmentMechanism() {
auto flagValue = useStateAlignmentMechanism_.load();

if (!flagValue.has_value()) {
// This block is not exclusive but it is not necessary.
// If multiple threads try to initialize the feature flag, we would only
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(51, "useStateAlignmentMechanism");

flagValue = currentProvider_->useStateAlignmentMechanism();
useStateAlignmentMechanism_ = flagValue;
}

return flagValue.value();
}

bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() {
auto flagValue = useTurboModuleInterop_.load();

Expand All @@ -974,7 +956,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(52, "useTurboModuleInterop");
markFlagAsAccessed(51, "useTurboModuleInterop");

flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
Expand All @@ -992,7 +974,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModules() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(53, "useTurboModules");
markFlagAsAccessed(52, "useTurboModules");

flagValue = currentProvider_->useTurboModules();
useTurboModules_ = flagValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<5f2c9b500fc26e68d56efae08b15575f>>
* @generated SignedSource<<2b2db46f819ffb208fba052aee5f2fc6>>
*/

/**
Expand Down Expand Up @@ -82,7 +82,6 @@ class ReactNativeFeatureFlagsAccessor {
bool useOptimizedEventBatchingOnAndroid();
bool useRuntimeShadowNodeReferenceUpdate();
bool useRuntimeShadowNodeReferenceUpdateOnLayout();
bool useStateAlignmentMechanism();
bool useTurboModuleInterop();
bool useTurboModules();

Expand All @@ -95,7 +94,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;

std::array<std::atomic<const char*>, 54> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 53> accessedFeatureFlags_;

std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> allowRecursiveCommitsWithSynchronousMountOnAndroid_;
Expand Down Expand Up @@ -148,7 +147,6 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> useOptimizedEventBatchingOnAndroid_;
std::atomic<std::optional<bool>> useRuntimeShadowNodeReferenceUpdate_;
std::atomic<std::optional<bool>> useRuntimeShadowNodeReferenceUpdateOnLayout_;
std::atomic<std::optional<bool>> useStateAlignmentMechanism_;
std::atomic<std::optional<bool>> useTurboModuleInterop_;
std::atomic<std::optional<bool>> useTurboModules_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<fb3d7a930222a40e9a8c377989713b07>>
* @generated SignedSource<<0520639ff05f8bc2199de7be3b26e6e0>>
*/

/**
Expand Down Expand Up @@ -231,10 +231,6 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}

bool useStateAlignmentMechanism() override {
return false;
}

bool useTurboModuleInterop() override {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<aaa516b2c719cb871f08c65bd7ce072f>>
* @generated SignedSource<<83348430670eef22eb555b4048805fbb>>
*/

/**
Expand Down Expand Up @@ -76,7 +76,6 @@ class ReactNativeFeatureFlagsProvider {
virtual bool useOptimizedEventBatchingOnAndroid() = 0;
virtual bool useRuntimeShadowNodeReferenceUpdate() = 0;
virtual bool useRuntimeShadowNodeReferenceUpdateOnLayout() = 0;
virtual bool useStateAlignmentMechanism() = 0;
virtual bool useTurboModuleInterop() = 0;
virtual bool useTurboModules() = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<2b484558d552981e4ec0644d75849dde>>
* @generated SignedSource<<530400259d51b9eeccdd0bcb78e5f8e1>>
*/

/**
Expand Down Expand Up @@ -292,11 +292,6 @@ bool NativeReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdateOnLayout(
return ReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdateOnLayout();
}

bool NativeReactNativeFeatureFlags::useStateAlignmentMechanism(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::useStateAlignmentMechanism();
}

bool NativeReactNativeFeatureFlags::useTurboModuleInterop(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::useTurboModuleInterop();
Expand Down
Loading

0 comments on commit b70f675

Please sign in to comment.