Skip to content

Commit

Permalink
Introduce ReactNativeFeatureFlag enableDeletionOfUnmountedViews (face…
Browse files Browse the repository at this point in the history
…book#46467)

Summary:
Pull Request resolved: facebook#46467

This diff introduces a new feature flag called ReactNativeFeatureFlag.enableDeletionOfUnmountedViews, which will ensure that pre-allocated views that were never mounted on the screen are deleted as soon as the shadow node is deleted from JS

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D62559188

fbshipit-source-id: 61f19a6dd38536de9f70fecc2937793681036f68
  • Loading branch information
mdvacca authored and facebook-github-bot committed Sep 13, 2024
1 parent 6f84b63 commit 70188fe
Show file tree
Hide file tree
Showing 19 changed files with 161 additions and 59 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<<b9b1988a78ba67a99027372dab215d06>>
* @generated SignedSource<<43a7bd07cf5236aa9357e5c1de87151a>>
*/

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

/**
* Deletes views that were pre-allocated but never mounted on the screen.
*/
@JvmStatic
public fun enableDeletionOfUnmountedViews(): Boolean = accessor.enableDeletionOfUnmountedViews()

/**
* Feature flag to configure eager attachment of the root view/initialisation of the JS code.
*/
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<<ae270cbe5e211d74cc056511be4ead16>>
* @generated SignedSource<<658604b78e381f97e41b0feedb6ff1c3>>
*/

/**
Expand All @@ -30,6 +30,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var enableAndroidMixBlendModePropCache: Boolean? = null
private var enableBackgroundStyleApplicatorCache: Boolean? = null
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableDeletionOfUnmountedViewsCache: Boolean? = null
private var enableEagerRootViewAttachmentCache: Boolean? = null
private var enableEventEmitterRetentionDuringGesturesOnAndroidCache: Boolean? = null
private var enableFabricLogsCache: Boolean? = null
Expand Down Expand Up @@ -161,6 +162,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

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

override fun enableEagerRootViewAttachment(): Boolean {
var cached = enableEagerRootViewAttachmentCache
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<<66a5f1eb19c081e178077b40fba27d93>>
* @generated SignedSource<<9b8a7242404f7f1e3c3c6590413db128>>
*/

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

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

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

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

@DoNotStrip @JvmStatic public external fun enableEventEmitterRetentionDuringGesturesOnAndroid(): 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<<25a422b93ab27473bfccabf653b1e196>>
* @generated SignedSource<<a8e719f4345d0a526bb62f5f42c4d6c5>>
*/

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

override fun enableCleanTextInputYogaNode(): Boolean = false

override fun enableDeletionOfUnmountedViews(): Boolean = false

override fun enableEagerRootViewAttachment(): Boolean = false

override fun enableEventEmitterRetentionDuringGesturesOnAndroid(): 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<<d18208e5018340e48e3c20b6a80ecccd>>
* @generated SignedSource<<8d55bf40875d6544f2d8524035cb773e>>
*/

/**
Expand Down Expand Up @@ -34,6 +34,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var enableAndroidMixBlendModePropCache: Boolean? = null
private var enableBackgroundStyleApplicatorCache: Boolean? = null
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableDeletionOfUnmountedViewsCache: Boolean? = null
private var enableEagerRootViewAttachmentCache: Boolean? = null
private var enableEventEmitterRetentionDuringGesturesOnAndroidCache: Boolean? = null
private var enableFabricLogsCache: Boolean? = null
Expand Down Expand Up @@ -175,6 +176,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

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

override fun enableEagerRootViewAttachment(): Boolean {
var cached = enableEagerRootViewAttachmentCache
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<<2e20df15ed5c75e0749eeead23b3c9dc>>
* @generated SignedSource<<4b0ce21f608338f4c8cb3bb5830b4965>>
*/

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

@DoNotStrip public fun enableCleanTextInputYogaNode(): Boolean

@DoNotStrip public fun enableDeletionOfUnmountedViews(): Boolean

@DoNotStrip public fun enableEagerRootViewAttachment(): Boolean

@DoNotStrip public fun enableEventEmitterRetentionDuringGesturesOnAndroid(): 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<<4ae4df54833e6fc817d73fe7cb7d1887>>
* @generated SignedSource<<f87375ebbf889045c449769fdf6018ba>>
*/

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

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

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

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

bool JReactNativeFeatureFlagsCxxInterop::enableEagerRootViewAttachment(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableEagerRootViewAttachment();
Expand Down Expand Up @@ -640,6 +651,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableCleanTextInputYogaNode",
JReactNativeFeatureFlagsCxxInterop::enableCleanTextInputYogaNode),
makeNativeMethod(
"enableDeletionOfUnmountedViews",
JReactNativeFeatureFlagsCxxInterop::enableDeletionOfUnmountedViews),
makeNativeMethod(
"enableEagerRootViewAttachment",
JReactNativeFeatureFlagsCxxInterop::enableEagerRootViewAttachment),
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<<a46a48a0f3c1a84badde0aa5618faf84>>
* @generated SignedSource<<dbbc50cc1093a1ce89a10f8679a06846>>
*/

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

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

static bool enableEagerRootViewAttachment(
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<<5df8c423af27ec25003d26a67ec1ef56>>
* @generated SignedSource<<69f2b48b14a886ed2c214441fdfc4f09>>
*/

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

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

bool ReactNativeFeatureFlags::enableEagerRootViewAttachment() {
return getAccessor().enableEagerRootViewAttachment();
}
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<<631e0b3e36325d36803b7e6fbefe2644>>
* @generated SignedSource<<be7334d60768774b87c270df8a640acc>>
*/

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

/**
* Deletes views that were pre-allocated but never mounted on the screen.
*/
RN_EXPORT static bool enableDeletionOfUnmountedViews();

/**
* Feature flag to configure eager attachment of the root view/initialisation of the JS code.
*/
Expand Down
Loading

0 comments on commit 70188fe

Please sign in to comment.