Add option to disable sending scroll events to Paper

Summary:
Changelog: [internal]

Originally added in D17814260 (https://github.com/facebook/react-native/commit/ffc7ec992c66417039b0fa14f1afd54a9cd2f882) to make parallax effect work in Dating.

This diff hides it behind a flag so we can properly evaluate what's the cost of sending scroll events to Paper.

Reviewed By: JoshuaGross

Differential Revision: D28608283

fbshipit-source-id: fa4d8944ad6b5e767363e231942f13fec9d18cb5
This commit is contained in:
Samuel Susla
2021-05-22 12:19:05 -07:00
committed by Facebook GitHub Bot
parent 0510821170
commit 4bec099f7e
4 changed files with 30 additions and 1 deletions
+6
View File
@@ -17,6 +17,12 @@ RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollec
RCT_EXTERN BOOL RCTExperimentGetOnDemandViewMounting(void);
RCT_EXTERN void RCTExperimentSetOnDemandViewMounting(BOOL value);
/*
* Allows sending scroll events to Paper.
*/
RCT_EXTERN BOOL RCTExperimentGetSendScrollEventToPaper(void);
RCT_EXTERN void RCTExperimentSetSendScrollEventToPaper(BOOL value);
/*
* Preemptive View Allocation
*/
+15
View File
@@ -25,6 +25,21 @@ void RCTExperimentSetOnDemandViewMounting(BOOL value)
RCTExperimentOnDemandViewMounting = value;
}
/*
* Send scroll events to Paper.
*/
static BOOL RCTExperimentSendScrollEventToPaper = YES;
BOOL RCTExperimentGetSendScrollEventToPaper()
{
return RCTExperimentSendScrollEventToPaper;
}
void RCTExperimentSetSendScrollEventToPaper(BOOL value)
{
RCTExperimentSendScrollEventToPaper = value;
}
/*
* Preemptive View Allocation
*/
@@ -87,6 +87,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
BOOL _isUserTriggeredScrolling;
BOOL _isOnDemandViewMountingEnabled;
BOOL _sendScrollEventToPaper;
CGPoint _contentOffsetWhenClipped;
NSMutableArray<UIView<RCTComponentViewProtocol> *> *_childComponentViews;
}
@@ -106,6 +107,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
_props = defaultProps;
_isOnDemandViewMountingEnabled = RCTExperimentGetOnDemandViewMounting();
_sendScrollEventToPaper = RCTExperimentGetSendScrollEventToPaper();
_childComponentViews = [[NSMutableArray alloc] init];
_scrollView = [[RCTEnhancedScrollView alloc] initWithFrame:self.bounds];
@@ -419,7 +421,9 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
}
// Once Fabric implements proper NativeAnimationDriver, this should be removed.
// This is just a workaround to allow animations based on onScroll event.
RCTSendPaperScrollEvent_DEPRECATED(scrollView, self.tag);
if (_sendScrollEventToPaper) {
RCTSendPaperScrollEvent_DEPRECATED(scrollView, self.tag);
}
}
[self _remountChildrenIfNeeded];
+4
View File
@@ -257,6 +257,10 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
RCTExperimentSetOnDemandViewMounting(YES);
}
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:disable_sending_scroll_events_to_paper")) {
RCTExperimentSetSendScrollEventToPaper(NO);
}
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:preemptive_view_allocation_disabled_ios")) {
RCTExperimentSetPreemptiveViewAllocationDisabled(YES);
}