Skip to content

Commit 410966a

Browse files
yungstersmeta-codesync[bot]
authored andcommitted
Fling: Cleanup enableVirtualViewRenderState (react#55095)
Summary: Pull Request resolved: react#55095 Deletes the `enableVirtualViewRenderState` feature flag and applies the new behavior everywhere. Changelog: [Internal] Differential Revision: D90334878
1 parent beab50c commit 410966a

23 files changed

Lines changed: 82 additions & 216 deletions

packages/react-native/React/Fabric/Mounting/ComponentViews/VirtualView/RCTVirtualViewComponentView.mm

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,16 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
7070
}
7171
}
7272

73-
// If disabled, `_renderState` will always be `RCTVirtualViewRenderStateUnknown`.
74-
if (ReactNativeFeatureFlags::enableVirtualViewRenderState()) {
75-
switch (newViewProps.renderState) {
76-
case 1:
77-
_renderState = RCTVirtualViewRenderStateRendered;
78-
break;
79-
case 2:
80-
_renderState = RCTVirtualViewRenderStateNone;
81-
break;
82-
default:
83-
_renderState = RCTVirtualViewRenderStateUnknown;
84-
break;
85-
}
73+
switch (newViewProps.renderState) {
74+
case 1:
75+
_renderState = RCTVirtualViewRenderStateRendered;
76+
break;
77+
case 2:
78+
_renderState = RCTVirtualViewRenderStateNone;
79+
break;
80+
default:
81+
_renderState = RCTVirtualViewRenderStateUnknown;
82+
break;
8683
}
8784

8885
const auto &newBaseViewProps = static_cast<const ViewProps &>(*props);
@@ -196,17 +193,13 @@ - (void)onModeChange:(RCTVirtualViewMode)newMode targetRect:(CGRect)targetRect t
196193

197194
switch (newMode) {
198195
case RCTVirtualViewModeVisible:
199-
if (_renderState == RCTVirtualViewRenderStateUnknown) {
200-
// Feature flag is disabled, so use the former logic.
196+
// If the previous mode was hidden, emit a mode change even if `renderState` is rendered,
197+
// because the hidden mode change is still pending and will eventually be committed. Only
198+
// skip emitting a mode change if the previous mode was prerender and the result of that
199+
// event has already been committed.
200+
if (!oldMode.has_value() || oldMode == RCTVirtualViewModeHidden ||
201+
_renderState != RCTVirtualViewRenderStateRendered) {
201202
[self _dispatchSyncModeChange:event];
202-
} else {
203-
// If the previous mode was prerender and the result of dispatching that event was committed, we do not need
204-
// to dispatch an event for visible.
205-
const auto wasPrerenderCommitted = oldMode.has_value() && oldMode == RCTVirtualViewModePrerender &&
206-
_renderState == RCTVirtualViewRenderStateRendered;
207-
if (!wasPrerenderCommitted) {
208-
[self _dispatchSyncModeChange:event];
209-
}
210203
}
211204
break;
212205
case RCTVirtualViewModePrerender:

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<91ad23aa529522a802b8d03198d7ccb9>>
7+
* @generated SignedSource<<e12e5425f1a51acfd0f244e5d4f46a3e>>
88
*/
99

1010
/**
@@ -342,12 +342,6 @@ public object ReactNativeFeatureFlags {
342342
@JvmStatic
343343
public fun enableVirtualViewDebugFeatures(): Boolean = accessor.enableVirtualViewDebugFeatures()
344344

345-
/**
346-
* Enables reading render state when dispatching VirtualView events.
347-
*/
348-
@JvmStatic
349-
public fun enableVirtualViewRenderState(): Boolean = accessor.enableVirtualViewRenderState()
350-
351345
/**
352346
* Uses the default event priority instead of the discreet event priority by default when dispatching events from Fabric to React.
353347
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<6188f6b73c835b514bd13de3b7a3f55c>>
7+
* @generated SignedSource<<fe103b59da0f78a6e834ca92603531fb>>
88
*/
99

1010
/**
@@ -72,7 +72,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
7272
private var enableViewRecyclingForViewCache: Boolean? = null
7373
private var enableVirtualViewContainerStateExperimentalCache: Boolean? = null
7474
private var enableVirtualViewDebugFeaturesCache: Boolean? = null
75-
private var enableVirtualViewRenderStateCache: Boolean? = null
7675
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
7776
private var fixTextClippingAndroid15useBoundsForWidthCache: Boolean? = null
7877
private var fuseboxAssertSingleHostStateCache: Boolean? = null
@@ -573,15 +572,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
573572
return cached
574573
}
575574

576-
override fun enableVirtualViewRenderState(): Boolean {
577-
var cached = enableVirtualViewRenderStateCache
578-
if (cached == null) {
579-
cached = ReactNativeFeatureFlagsCxxInterop.enableVirtualViewRenderState()
580-
enableVirtualViewRenderStateCache = cached
581-
}
582-
return cached
583-
}
584-
585575
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean {
586576
var cached = fixMappingOfEventPrioritiesBetweenFabricAndReactCache
587577
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<2528d994ff2ed6ada21f7ff67cdfcd0a>>
7+
* @generated SignedSource<<0ae5a806950b4bfaaaccde774114ab4e>>
88
*/
99

1010
/**
@@ -132,8 +132,6 @@ public object ReactNativeFeatureFlagsCxxInterop {
132132

133133
@DoNotStrip @JvmStatic public external fun enableVirtualViewDebugFeatures(): Boolean
134134

135-
@DoNotStrip @JvmStatic public external fun enableVirtualViewRenderState(): Boolean
136-
137135
@DoNotStrip @JvmStatic public external fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
138136

139137
@DoNotStrip @JvmStatic public external fun fixTextClippingAndroid15useBoundsForWidth(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<c9a6da699b29672243ed2535007f3eb2>>
7+
* @generated SignedSource<<532504ff7b4a7f4c45649fc59ecade3a>>
88
*/
99

1010
/**
@@ -127,8 +127,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
127127

128128
override fun enableVirtualViewDebugFeatures(): Boolean = false
129129

130-
override fun enableVirtualViewRenderState(): Boolean = true
131-
132130
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean = false
133131

134132
override fun fixTextClippingAndroid15useBoundsForWidth(): Boolean = false

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<f691287ee63dfd86f0a1f5a8c16cb0be>>
7+
* @generated SignedSource<<d4caae6713b5c26f17841839903ea529>>
88
*/
99

1010
/**
@@ -76,7 +76,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
7676
private var enableViewRecyclingForViewCache: Boolean? = null
7777
private var enableVirtualViewContainerStateExperimentalCache: Boolean? = null
7878
private var enableVirtualViewDebugFeaturesCache: Boolean? = null
79-
private var enableVirtualViewRenderStateCache: Boolean? = null
8079
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
8180
private var fixTextClippingAndroid15useBoundsForWidthCache: Boolean? = null
8281
private var fuseboxAssertSingleHostStateCache: Boolean? = null
@@ -629,16 +628,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
629628
return cached
630629
}
631630

632-
override fun enableVirtualViewRenderState(): Boolean {
633-
var cached = enableVirtualViewRenderStateCache
634-
if (cached == null) {
635-
cached = currentProvider.enableVirtualViewRenderState()
636-
accessedFeatureFlags.add("enableVirtualViewRenderState")
637-
enableVirtualViewRenderStateCache = cached
638-
}
639-
return cached
640-
}
641-
642631
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean {
643632
var cached = fixMappingOfEventPrioritiesBetweenFabricAndReactCache
644633
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<f229d1a748eb05b6d796275a68cd636d>>
7+
* @generated SignedSource<<351ae3b05fae543b52eaa7bcf7f5f479>>
88
*/
99

1010
/**
@@ -127,8 +127,6 @@ public interface ReactNativeFeatureFlagsProvider {
127127

128128
@DoNotStrip public fun enableVirtualViewDebugFeatures(): Boolean
129129

130-
@DoNotStrip public fun enableVirtualViewRenderState(): Boolean
131-
132130
@DoNotStrip public fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
133131

134132
@DoNotStrip public fun fixTextClippingAndroid15useBoundsForWidth(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/virtual/view/ReactVirtualView.kt

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,21 @@ public class ReactVirtualView(context: Context) :
155155

156156
when (newMode) {
157157
VirtualViewMode.Visible -> {
158-
if (renderState == VirtualViewRenderState.Unknown) {
159-
// Feature flag is disabled, so use the former logic.
158+
// If the previous mode was hidden, emit a mode change even if `renderState` is rendered,
159+
// because the hidden mode change is still pending and will eventually be committed. Only
160+
// skip emitting a mode change if the previous mode was prerender and the result of that
161+
// event has already been committed.
162+
if (
163+
oldMode == null ||
164+
oldMode == VirtualViewMode.Hidden ||
165+
renderState != VirtualViewRenderState.Rendered
166+
) {
160167
modeChangeEmitter?.emitModeChange(
161168
VirtualViewMode.Visible,
162169
containerRelativeRect,
163170
thresholdRect,
164171
synchronous = true,
165172
)
166-
} else {
167-
// If the previous mode was prerender and the result of dispatching that event was
168-
// committed, we do not need to dispatch an event for visible.
169-
val wasPrerenderCommitted =
170-
oldMode == VirtualViewMode.Prerender && renderState == VirtualViewRenderState.Rendered
171-
if (!wasPrerenderCommitted) {
172-
modeChangeEmitter?.emitModeChange(
173-
VirtualViewMode.Visible,
174-
containerRelativeRect,
175-
thresholdRect,
176-
synchronous = true,
177-
)
178-
}
179173
}
180174
}
181175
VirtualViewMode.Prerender -> {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/virtual/view/ReactVirtualViewManager.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package com.facebook.react.views.virtual.view
99

1010
import android.graphics.Rect
1111
import androidx.annotation.VisibleForTesting
12-
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
1312
import com.facebook.react.module.annotations.ReactModule
1413
import com.facebook.react.uimanager.ThemedReactContext
1514
import com.facebook.react.uimanager.UIManagerHelper
@@ -46,15 +45,12 @@ public class ReactVirtualViewManager :
4645

4746
@ReactProp(name = "renderState")
4847
override fun setRenderState(view: ReactVirtualView, value: Int) {
49-
// If disabled, `renderState` will always be `VirtualViewRenderState.Unknown`.
50-
if (ReactNativeFeatureFlags.enableVirtualViewRenderState()) {
51-
view.renderState =
52-
when (value) {
53-
1 -> VirtualViewRenderState.Rendered
54-
2 -> VirtualViewRenderState.None
55-
else -> VirtualViewRenderState.Unknown
56-
}
57-
}
48+
view.renderState =
49+
when (value) {
50+
1 -> VirtualViewRenderState.Rendered
51+
2 -> VirtualViewRenderState.None
52+
else -> VirtualViewRenderState.Unknown
53+
}
5854
}
5955

6056
override fun setNativeId(view: ReactVirtualView, nativeId: String?) {

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<f88a6aeb9289fd48d083cfccfc609d79>>
7+
* @generated SignedSource<<9841e9badfe84669fde89f35467d4c13>>
88
*/
99

1010
/**
@@ -351,12 +351,6 @@ class ReactNativeFeatureFlagsJavaProvider
351351
return method(javaProvider_);
352352
}
353353

354-
bool enableVirtualViewRenderState() override {
355-
static const auto method =
356-
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableVirtualViewRenderState");
357-
return method(javaProvider_);
358-
}
359-
360354
bool fixMappingOfEventPrioritiesBetweenFabricAndReact() override {
361355
static const auto method =
362356
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("fixMappingOfEventPrioritiesBetweenFabricAndReact");
@@ -807,11 +801,6 @@ bool JReactNativeFeatureFlagsCxxInterop::enableVirtualViewDebugFeatures(
807801
return ReactNativeFeatureFlags::enableVirtualViewDebugFeatures();
808802
}
809803

810-
bool JReactNativeFeatureFlagsCxxInterop::enableVirtualViewRenderState(
811-
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
812-
return ReactNativeFeatureFlags::enableVirtualViewRenderState();
813-
}
814-
815804
bool JReactNativeFeatureFlagsCxxInterop::fixMappingOfEventPrioritiesBetweenFabricAndReact(
816805
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
817806
return ReactNativeFeatureFlags::fixMappingOfEventPrioritiesBetweenFabricAndReact();
@@ -1154,9 +1143,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
11541143
makeNativeMethod(
11551144
"enableVirtualViewDebugFeatures",
11561145
JReactNativeFeatureFlagsCxxInterop::enableVirtualViewDebugFeatures),
1157-
makeNativeMethod(
1158-
"enableVirtualViewRenderState",
1159-
JReactNativeFeatureFlagsCxxInterop::enableVirtualViewRenderState),
11601146
makeNativeMethod(
11611147
"fixMappingOfEventPrioritiesBetweenFabricAndReact",
11621148
JReactNativeFeatureFlagsCxxInterop::fixMappingOfEventPrioritiesBetweenFabricAndReact),

0 commit comments

Comments
 (0)