Skip to content

fix shadow node state updates #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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<<3e10f8d2f623da3b7b502d8fa78f82a4>>
* @generated SignedSource<<99da5cf948e469e385bd70b4c59cd764>>
*/

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

/**
* Use the state stored on the source shadow node when cloning it instead of reading in the most recent state on the shadow node family.
*/
@JvmStatic
public fun useShadowNodeStateOnClone(): Boolean = accessor.useShadowNodeStateOnClone()

/**
* 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<<497bbb23778fe0f9763e9bfa715ea3aa>>
* @generated SignedSource<<5e1d8c0e728715d4110b6d1d156357c5>>
*/

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

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

override fun useShadowNodeStateOnClone(): Boolean {
var cached = useShadowNodeStateOnCloneCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.useShadowNodeStateOnClone()
useShadowNodeStateOnCloneCache = 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<<d801f87c988fbd921e2379f236e1711f>>
* @generated SignedSource<<b8035f8bf1833723858be474f7766594>>
*/

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

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

@DoNotStrip @JvmStatic public external fun useShadowNodeStateOnClone(): 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<<5de2cfc00f486b7d07266939ce18a397>>
* @generated SignedSource<<11d93a900862ed8ce98f90f9af2de47b>>
*/

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

override fun useRuntimeShadowNodeReferenceUpdate(): Boolean = true

override fun useShadowNodeStateOnClone(): 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<<f1ed4107e24ced5d2673bfb065573062>>
* @generated SignedSource<<0614fa80cbc66806fa45aef70f34e2d7>>
*/

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

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

override fun useShadowNodeStateOnClone(): Boolean {
var cached = useShadowNodeStateOnCloneCache
if (cached == null) {
cached = currentProvider.useShadowNodeStateOnClone()
accessedFeatureFlags.add("useShadowNodeStateOnClone")
useShadowNodeStateOnCloneCache = 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<<3cd802bdd1d383ea0668e43319d53b3f>>
* @generated SignedSource<<5f4ff90382b2d69df401535cb33e64c5>>
*/

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

@DoNotStrip public fun useRuntimeShadowNodeReferenceUpdate(): Boolean

@DoNotStrip public fun useShadowNodeStateOnClone(): 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<<7c3853858da56eb5f471abccf9dcbf55>>
* @generated SignedSource<<28069af1f34c79e9907c85697a291c0e>>
*/

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

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

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

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

bool JReactNativeFeatureFlagsCxxInterop::useTurboModuleInterop(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::useTurboModuleInterop();
Expand Down Expand Up @@ -698,6 +709,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"useRuntimeShadowNodeReferenceUpdate",
JReactNativeFeatureFlagsCxxInterop::useRuntimeShadowNodeReferenceUpdate),
makeNativeMethod(
"useShadowNodeStateOnClone",
JReactNativeFeatureFlagsCxxInterop::useShadowNodeStateOnClone),
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<<77b4ed5aa33290ba9da1719544e974cb>>
* @generated SignedSource<<763d595784bdf31a852ebf2a492a1393>>
*/

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

static bool useShadowNodeStateOnClone(
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<<7d301656072183649246db8fa738fc4d>>
* @generated SignedSource<<511c1667fab247b77d771a7a26e87b46>>
*/

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

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

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<<eee9560521020eb75fa84c6e0cef31a3>>
* @generated SignedSource<<19cfd8b41dd429c83a5e0f0df514d1d1>>
*/

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

/**
* Use the state stored on the source shadow node when cloning it instead of reading in the most recent state on the shadow node family.
*/
RN_EXPORT static bool useShadowNodeStateOnClone();

/**
* 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<<a360603ae99888aa172cc1b85d3893e4>>
* @generated SignedSource<<deee1bf6d0688e6871f59c300c985305>>
*/

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

bool ReactNativeFeatureFlagsAccessor::useShadowNodeStateOnClone() {
auto flagValue = useShadowNodeStateOnClone_.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(43, "useShadowNodeStateOnClone");

flagValue = currentProvider_->useShadowNodeStateOnClone();
useShadowNodeStateOnClone_ = flagValue;
}

return flagValue.value();
}

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

Expand All @@ -812,7 +830,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(43, "useTurboModuleInterop");
markFlagAsAccessed(44, "useTurboModuleInterop");

flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
Expand All @@ -830,7 +848,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(44, "useTurboModules");
markFlagAsAccessed(45, "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<<8eb2b5d6dd367826ff7bc899afbdea60>>
* @generated SignedSource<<2a6cbfd5de86a5bb840f1fc5f47c51a6>>
*/

/**
Expand Down Expand Up @@ -75,6 +75,7 @@ class ReactNativeFeatureFlagsAccessor {
bool useOptimizedEventBatchingOnAndroid();
bool useRawPropsJsiValue();
bool useRuntimeShadowNodeReferenceUpdate();
bool useShadowNodeStateOnClone();
bool useTurboModuleInterop();
bool useTurboModules();

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

std::array<std::atomic<const char*>, 45> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 46> accessedFeatureFlags_;

std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> completeReactInstanceCreationOnBgThreadOnAndroid_;
Expand Down Expand Up @@ -133,6 +134,7 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> useOptimizedEventBatchingOnAndroid_;
std::atomic<std::optional<bool>> useRawPropsJsiValue_;
std::atomic<std::optional<bool>> useRuntimeShadowNodeReferenceUpdate_;
std::atomic<std::optional<bool>> useShadowNodeStateOnClone_;
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<<e38a0e9474ac349a4b8153862470c856>>
* @generated SignedSource<<830cdd4b394262ee65abc63a54833674>>
*/

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

bool useShadowNodeStateOnClone() 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<<e5e8a3b63e42ed4b5cab143d46d20260>>
* @generated SignedSource<<627094b444d8b7a513d7190272848a9e>>
*/

/**
Expand Down Expand Up @@ -432,6 +432,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef
return ReactNativeFeatureFlagsDefaults::useRuntimeShadowNodeReferenceUpdate();
}

bool useShadowNodeStateOnClone() override {
auto value = values_["useShadowNodeStateOnClone"];
if (!value.isNull()) {
return value.getBool();
}

return ReactNativeFeatureFlagsDefaults::useShadowNodeStateOnClone();
}

bool useTurboModuleInterop() override {
auto value = values_["useTurboModuleInterop"];
if (!value.isNull()) {
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<<36bfe0037e4dba3b6eb6e95075914fce>>
* @generated SignedSource<<190bad7388fb33884eebca0fed4ad61f>>
*/

/**
Expand Down Expand Up @@ -68,6 +68,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool useOptimizedEventBatchingOnAndroid() = 0;
virtual bool useRawPropsJsiValue() = 0;
virtual bool useRuntimeShadowNodeReferenceUpdate() = 0;
virtual bool useShadowNodeStateOnClone() = 0;
virtual bool useTurboModuleInterop() = 0;
virtual bool useTurboModules() = 0;
};
Expand Down
Loading
Loading