Skip to content

Commit

Permalink
Migrate enableCppPropsIteratorSetter to ReactNativeFeatureFlags
Browse files Browse the repository at this point in the history
Summary:
Migrate enableCppPropsIteratorSetter to ReactNativeFeatureFlags

changelog: [internal] internal

Differential Revision: D60022936
  • Loading branch information
mdvacca committed Jul 23, 2024
1 parent bb23026 commit 1a9810d
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 63 deletions.
1 change: 0 additions & 1 deletion packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,6 @@ public class com/facebook/react/common/network/OkHttpCallUtil {
public class com/facebook/react/config/ReactFeatureFlags {
public static field dispatchPointerEvents Z
public static field enableBridgelessArchitecture Z
public static field enableCppPropsIteratorSetter Z
public static field enableEagerRootViewAttachment Z
public static field enableFabricLogs Z
public static field enableFabricRenderer Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ public class ReactFeatureFlags {
*/
public static boolean enableViewRecycling = false;

/**
* Enable prop iterator setter-style construction of Props in C++ (this flag is not used in Java).
*/
public static boolean enableCppPropsIteratorSetter = false;

/**
* Enables storing js caller stack when creating promise in native module. This is useful in case
* of Promise rejection and tracing the cause.
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<<4a2baeeff0b03f07a259028cf4446455>>
* @generated SignedSource<<1c5e38d08ed66da4e97f26fd3e95cad1>>
*/

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

/**
* Enable prop iterator setter-style construction of Props in C++ (this flag is not used in Java).
*/
@JvmStatic
public fun enableCppPropsIteratorSetter(): Boolean = accessor.enableCppPropsIteratorSetter()

/**
* When the app is completely migrated to Fabric, set this flag to true to disable parts of Paper infrastructure that are not needed anymore but consume memory and CPU. Specifically, UIViewOperationQueue and EventDispatcherImpl will no longer work as they will not subscribe to ReactChoreographer for updates.
*/
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<<7fbe53bfb2b06cdae8b1590c9131edbb>>
* @generated SignedSource<<9ff6454da9791815006daf45d50334bf>>
*/

/**
Expand All @@ -29,6 +29,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var destroyFabricSurfacesInReactInstanceManagerCache: Boolean? = null
private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableCppPropsIteratorSetterCache: Boolean? = null
private var enableFabricRendererExclusivelyCache: Boolean? = null
private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null
private var enableLongTaskAPICache: Boolean? = null
Expand Down Expand Up @@ -138,6 +139,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

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

override fun enableFabricRendererExclusively(): Boolean {
var cached = enableFabricRendererExclusivelyCache
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<<df4c04351e9713db7de1ecf4d8f8d435>>
* @generated SignedSource<<ef481e88451ca6efa0ee4c180b9e96b0>>
*/

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

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

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

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

@DoNotStrip @JvmStatic public external fun enableGranularShadowTreeStateReconciliation(): 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<<fcab38c9de5314e55ff64584b9221b9c>>
* @generated SignedSource<<e08359a65a4624e0a06e5b8324c57101>>
*/

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

override fun enableCleanTextInputYogaNode(): Boolean = false

override fun enableCppPropsIteratorSetter(): Boolean = false

override fun enableFabricRendererExclusively(): Boolean = false

override fun enableGranularShadowTreeStateReconciliation(): 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<<c740d546d8154130aeabdd3667c26473>>
* @generated SignedSource<<c7335f339340f3d37b63c8c4dfa050ec>>
*/

/**
Expand Down Expand Up @@ -33,6 +33,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var destroyFabricSurfacesInReactInstanceManagerCache: Boolean? = null
private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableCppPropsIteratorSetterCache: Boolean? = null
private var enableFabricRendererExclusivelyCache: Boolean? = null
private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null
private var enableLongTaskAPICache: Boolean? = null
Expand Down Expand Up @@ -151,6 +152,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

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

override fun enableFabricRendererExclusively(): Boolean {
var cached = enableFabricRendererExclusivelyCache
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<<c3138a9a6b90f5a35bcdda2928b759ed>>
* @generated SignedSource<<bcf9bc0fdf95e8fdf20e0342911ae7bb>>
*/

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

@DoNotStrip public fun enableCleanTextInputYogaNode(): Boolean

@DoNotStrip public fun enableCppPropsIteratorSetter(): Boolean

@DoNotStrip public fun enableFabricRendererExclusively(): Boolean

@DoNotStrip public fun enableGranularShadowTreeStateReconciliation(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ Binding::getInspectorDataForInstance(
return ReadableNativeMap::newObjectCxxArgs(result);
}

constexpr static auto kReactFeatureFlagsJavaDescriptor =
"com/facebook/react/config/ReactFeatureFlags";

static bool getFeatureFlagValue(const char* name) {
static const auto reactFeatureFlagsClass =
jni::findClassStatic(kReactFeatureFlagsJavaDescriptor);
const auto field = reactFeatureFlagsClass->getStaticField<jboolean>(name);
return reactFeatureFlagsClass->getStaticFieldValue(field);
}

void Binding::setPixelDensity(float pointScaleFactor) {
pointScaleFactor_ = pointScaleFactor;
}
Expand Down Expand Up @@ -404,7 +394,7 @@ void Binding::installFabricUIManager(
reactNativeConfig_ = config;

CoreFeatures::enablePropIteratorSetter =
getFeatureFlagValue("enableCppPropsIteratorSetter");
ReactNativeFeatureFlags::enableCppPropsIteratorSetter();
CoreFeatures::excludeYogaFromRawProps =
ReactNativeFeatureFlags::excludeYogaFromRawProps();

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<<7671fb85b168f4eb8713fe087a9f1e31>>
* @generated SignedSource<<a4f546d99bb176f829571f09097b1e3d>>
*/

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

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

bool enableFabricRendererExclusively() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableFabricRendererExclusively");
Expand Down Expand Up @@ -304,6 +310,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableCleanTextInputYogaNode(
return ReactNativeFeatureFlags::enableCleanTextInputYogaNode();
}

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

bool JReactNativeFeatureFlagsCxxInterop::enableFabricRendererExclusively(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableFabricRendererExclusively();
Expand Down Expand Up @@ -483,6 +494,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableCleanTextInputYogaNode",
JReactNativeFeatureFlagsCxxInterop::enableCleanTextInputYogaNode),
makeNativeMethod(
"enableCppPropsIteratorSetter",
JReactNativeFeatureFlagsCxxInterop::enableCppPropsIteratorSetter),
makeNativeMethod(
"enableFabricRendererExclusively",
JReactNativeFeatureFlagsCxxInterop::enableFabricRendererExclusively),
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<<06b35c2faaf073589042046179aaf65a>>
* @generated SignedSource<<73a3ccdcaaf8a7701dd928ab41364aee>>
*/

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

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

static bool enableFabricRendererExclusively(
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<<541ad52f8b28ce4f72da4ce00cc7ba0e>>
* @generated SignedSource<<a74a3a437466092953ffce9f57217f2d>>
*/

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

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

bool ReactNativeFeatureFlags::enableFabricRendererExclusively() {
return getAccessor().enableFabricRendererExclusively();
}
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<<8d5e69e5a5bab6f48008f2b68f1a3126>>
* @generated SignedSource<<37ec1d4e7c87c3dcf07087d07b48c27a>>
*/

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

/**
* Enable prop iterator setter-style construction of Props in C++ (this flag is not used in Java).
*/
RN_EXPORT static bool enableCppPropsIteratorSetter();

/**
* When the app is completely migrated to Fabric, set this flag to true to disable parts of Paper infrastructure that are not needed anymore but consume memory and CPU. Specifically, UIViewOperationQueue and EventDispatcherImpl will no longer work as they will not subscribe to ReactChoreographer for updates.
*/
Expand Down
Loading

0 comments on commit 1a9810d

Please sign in to comment.