Do not register RCTSurfacePresenterObserver for animatedShouldSignalBatch (#50247)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50247

Rather than nooping the RCTSurfacePresenterObserver in RCTNativeAnimatedTurboModule, we should just not register the observer when using ReactNativeFeatureFlags::animatedShouldSignalBatch.

## Changelog

[Internal]

Reviewed By: shwanton

Differential Revision: D71735004

fbshipit-source-id: 5176497197314a9b07fc9bd77828f7a2af2650ea
This commit is contained in:
Eric Rozell
2025-03-25 13:19:36 -07:00
committed by Facebook GitHub Bot
parent bffb414291
commit c920b7f54a
@@ -51,7 +51,9 @@ RCT_EXPORT_MODULE();
{
// _surfacePresenter set in setSurfacePresenter:
_nodesManager = [[RCTNativeAnimatedNodesManager alloc] initWithBridge:nil surfacePresenter:_surfacePresenter];
[_surfacePresenter addObserver:self];
if (!facebook::react::ReactNativeFeatureFlags::animatedShouldSignalBatch()) {
[_surfacePresenter addObserver:self];
}
[[self.moduleRegistry moduleForName:"EventDispatcher"] addDispatchObserver:self];
}
@@ -60,7 +62,9 @@ RCT_EXPORT_MODULE();
[super invalidate];
[_nodesManager stopAnimationLoop];
[[self.moduleRegistry moduleForName:"EventDispatcher"] removeDispatchObserver:self];
[_surfacePresenter removeObserver:self];
if (!facebook::react::ReactNativeFeatureFlags::animatedShouldSignalBatch()) {
[_surfacePresenter removeObserver:self];
}
}
/*
@@ -325,10 +329,6 @@ RCT_EXPORT_METHOD(queueAndExecuteBatchedOperations : (NSArray *)operationsAndArg
- (void)willMountComponentsWithRootTag:(NSInteger)rootTag
{
if (facebook::react::ReactNativeFeatureFlags::animatedShouldSignalBatch()) {
return;
}
RCTAssertMainQueue();
RCTExecuteOnUIManagerQueue(^{
NSArray<AnimatedOperation> *preOperations = self->_preOperations;
@@ -344,10 +344,6 @@ RCT_EXPORT_METHOD(queueAndExecuteBatchedOperations : (NSArray *)operationsAndArg
- (void)didMountComponentsWithRootTag:(NSInteger)rootTag
{
if (facebook::react::ReactNativeFeatureFlags::animatedShouldSignalBatch()) {
return;
}
RCTAssertMainQueue();
RCTExecuteOnUIManagerQueue(^{
NSArray<AnimatedOperation> *operations = self->_operations;