Skip to content

Commit

Permalink
Migrate enableGranularScrollViewStateUpdatesIOS to ReactNativeFeature…
Browse files Browse the repository at this point in the history
…Flags

Differential Revision: D60131784
  • Loading branch information
mdvacca committed Jul 24, 2024
1 parent 92155c4 commit ddd17a0
Show file tree
Hide file tree
Showing 23 changed files with 153 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <React/RCTConstants.h>
#import <React/RCTScrollEvent.h>

#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/renderer/components/scrollview/RCTComponentViewHelpers.h>
#import <react/renderer/components/scrollview/ScrollViewComponentDescriptor.h>
#import <react/renderer/components/scrollview/ScrollViewEventEmitter.h>
Expand Down Expand Up @@ -502,7 +503,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
});
}
} else {
if (!_isUserTriggeredScrolling || CoreFeatures::enableGranularScrollViewStateUpdatesIOS) {
if (!_isUserTriggeredScrolling || ReactNativeFeatureFlags::enableGranularScrollViewStateUpdatesIOS()) {
[self _updateStateWithContentOffset];
}

Expand Down
7 changes: 0 additions & 7 deletions packages/react-native/React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#import <react/renderer/scheduler/AsynchronousEventBeat.h>
#import <react/renderer/scheduler/SchedulerToolbox.h>
#import <react/utils/ContextContainer.h>
#import <react/utils/CoreFeatures.h>
#import <react/utils/ManagedObjectWrapper.h>

#import "PlatformRunLoopObserver.h"
Expand Down Expand Up @@ -227,12 +226,6 @@ - (BOOL)resume

- (RCTScheduler *)_createScheduler
{
auto reactNativeConfig = _contextContainer->at<std::shared_ptr<const ReactNativeConfig>>("ReactNativeConfig");

if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_granular_scroll_view_state_updates_ios")) {
CoreFeatures::enableGranularScrollViewStateUpdatesIOS = true;
}

auto componentRegistryFactory =
[factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)](
const EventDispatcher::Weak &eventDispatcher, const ContextContainer::Shared &contextContainer) {
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<<5c7964726373a75fab5d6473bf7d6390>>
* @generated SignedSource<<bd375056cfcd982392e7eb25b5806f18>>
*/

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

/**
* When enabled, RCTScrollViewComponentView will trigger ShadowTree state updates for all changes in scroll position.
*/
@JvmStatic
public fun enableGranularScrollViewStateUpdatesIOS(): Boolean = accessor.enableGranularScrollViewStateUpdatesIOS()

/**
* When enabled, the renderer would only fail commits when they propagate state and the last commit that updated state changed before committing.
*/
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<<c0a9c3de094bf2c9d580b8d79e5de47b>>
* @generated SignedSource<<3792bade51d906046c772bda42edaa09>>
*/

/**
Expand Down Expand Up @@ -33,6 +33,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var enableEagerRootViewAttachmentCache: Boolean? = null
private var enableFabricLogsCache: Boolean? = null
private var enableFabricRendererExclusivelyCache: Boolean? = null
private var enableGranularScrollViewStateUpdatesIOSCache: Boolean? = null
private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null
private var enableLongTaskAPICache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
Expand Down Expand Up @@ -180,6 +181,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

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

override fun enableGranularShadowTreeStateReconciliation(): Boolean {
var cached = enableGranularShadowTreeStateReconciliationCache
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<<3837dde4571d8da810192d1a6ed9931f>>
* @generated SignedSource<<77a1724d3b923becb1c19ec99dd0fb14>>
*/

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

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

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

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

@DoNotStrip @JvmStatic public external fun enableLongTaskAPI(): 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<<aa3b1f6e52ccb44cc90e2096a7bdcf91>>
* @generated SignedSource<<a391d1062f5e22cdd006d828458c2cfa>>
*/

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

override fun enableFabricRendererExclusively(): Boolean = false

override fun enableGranularScrollViewStateUpdatesIOS(): Boolean = false

override fun enableGranularShadowTreeStateReconciliation(): Boolean = false

override fun enableLongTaskAPI(): 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<<ac064cdc77d4375aa34118b1607de52f>>
* @generated SignedSource<<d064efab052e645cfec4243019308a71>>
*/

/**
Expand Down Expand Up @@ -37,6 +37,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var enableEagerRootViewAttachmentCache: Boolean? = null
private var enableFabricLogsCache: Boolean? = null
private var enableFabricRendererExclusivelyCache: Boolean? = null
private var enableGranularScrollViewStateUpdatesIOSCache: Boolean? = null
private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null
private var enableLongTaskAPICache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
Expand Down Expand Up @@ -197,6 +198,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

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

override fun enableGranularShadowTreeStateReconciliation(): Boolean {
var cached = enableGranularShadowTreeStateReconciliationCache
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<<ac9f91956cff38f56bd2b984b4288c57>>
* @generated SignedSource<<d31117214f5f1e9109122f45f2fbc024>>
*/

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

@DoNotStrip public fun enableFabricRendererExclusively(): Boolean

@DoNotStrip public fun enableGranularScrollViewStateUpdatesIOS(): Boolean

@DoNotStrip public fun enableGranularShadowTreeStateReconciliation(): Boolean

@DoNotStrip public fun enableLongTaskAPI(): 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<<1fa4fea1bd8055330de591d6ee315b12>>
* @generated SignedSource<<bc4237aa0a7705ab2a85f6190cf6526f>>
*/

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

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

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

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

bool JReactNativeFeatureFlagsCxxInterop::enableGranularShadowTreeStateReconciliation(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation();
Expand Down Expand Up @@ -561,6 +572,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableFabricRendererExclusively",
JReactNativeFeatureFlagsCxxInterop::enableFabricRendererExclusively),
makeNativeMethod(
"enableGranularScrollViewStateUpdatesIOS",
JReactNativeFeatureFlagsCxxInterop::enableGranularScrollViewStateUpdatesIOS),
makeNativeMethod(
"enableGranularShadowTreeStateReconciliation",
JReactNativeFeatureFlagsCxxInterop::enableGranularShadowTreeStateReconciliation),
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<<e0cbf15721fa34aab83adb41580517ab>>
* @generated SignedSource<<1d277bf5b52d0c6b0f692b135122313d>>
*/

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

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

static bool enableGranularShadowTreeStateReconciliation(
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<<fc990d89982314febeb85bf3ebc2d6f5>>
* @generated SignedSource<<2b872353f06665054445ac161319c5ee>>
*/

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

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

bool ReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation() {
return getAccessor().enableGranularShadowTreeStateReconciliation();
}
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<<bd744fbaf219b4ca7e8825c5767d9c68>>
* @generated SignedSource<<fb82dfb059a684192d8217f33c868341>>
*/

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

/**
* When enabled, RCTScrollViewComponentView will trigger ShadowTree state updates for all changes in scroll position.
*/
RN_EXPORT static bool enableGranularScrollViewStateUpdatesIOS();

/**
* When enabled, the renderer would only fail commits when they propagate state and the last commit that updated state changed before committing.
*/
Expand Down
Loading

0 comments on commit ddd17a0

Please sign in to comment.