From c920b7f54abcbbb05f4f74aaadab4d696dd3f32b Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Tue, 25 Mar 2025 13:19:36 -0700 Subject: [PATCH] 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 --- .../RCTNativeAnimatedTurboModule.mm | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm b/packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm index 5f0988e1380..f9b94278f06 100644 --- a/packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm +++ b/packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm @@ -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 *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 *operations = self->_operations;