Skip to content

Commit 6529383

Browse files
RSNarafacebook-github-bot
authored andcommitted
Always flush in NativeAnimatedTurboModule
Summary: ## Summary In the past, NativeAnimatedModule could animate **both** Paper **and** Fabric components. For Fabric nodes, we needed to manually flush NativeAnimatedModule's operations queue. So, we started tracking which nodes were Fabric owned in NativeAnimatedModule. ## Changes With bridgeless mode, all components must be Fabric-owned. So, should be able to remove this fabric ownership tracking logic and **always flush.** ## Is this safe? In the worst case, we over-flush. This doesn't seem bad. cc sammy-SC. ## Do we still need flushing? Arguably, all this manual flushing should be unnecessary, because we already migrated AnimatedModule's Paper integration to RCTSurfacePresenterObserver, here: D14336760 (544d9fb). So, do we still need this flushing? Yes. Here's what happens when you disable all the manual flushing in bridgeless mode: https://pxl.cl/2dqPf. Long-term, we need to re-think this operations queuing in NativeAnimatedTurboModule. I left my thoughts in T130668424 (Investigation - Day 5). Changelog: [Internal] Reviewed By: p-sun Differential Revision: D39592477 fbshipit-source-id: e971edc0d99661a37b5f430bce46c78acaa121c0
1 parent 6ba5fa9 commit 6529383

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ @implementation RCTNativeAnimatedTurboModule
2626
NSMutableArray<AnimatedOperation> *_operations;
2727
// Operations called before views have been updated.
2828
NSMutableArray<AnimatedOperation> *_preOperations;
29-
NSMutableDictionary<NSNumber *, NSNumber *> *_animIdIsManagedByFabric;
30-
// A set of nodeIDs managed by Fabric.
31-
NSMutableSet<NSNumber *> *_nodeIDsManagedByFabric;
3229
}
3330

3431
RCT_EXPORT_MODULE();
@@ -43,8 +40,6 @@ - (instancetype)init
4340
if (self = [super init]) {
4441
_operations = [NSMutableArray new];
4542
_preOperations = [NSMutableArray new];
46-
_animIdIsManagedByFabric = [NSMutableDictionary new];
47-
_nodeIDsManagedByFabric = [NSMutableSet new];
4843
}
4944
return self;
5045
}
@@ -113,9 +108,6 @@ - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
113108
RCT_EXPORT_METHOD(connectAnimatedNodes:(double)parentTag
114109
childTag:(double)childTag)
115110
{
116-
if ([_nodeIDsManagedByFabric containsObject:@(childTag)]) {
117-
[_nodeIDsManagedByFabric addObject:@(parentTag)];
118-
}
119111
[self addOperationBlock:^(RCTNativeAnimatedNodesManager *nodesManager) {
120112
[nodesManager connectAnimatedNodes:[NSNumber numberWithDouble:parentTag] childTag:[NSNumber numberWithDouble:childTag]];
121113
}];
@@ -138,21 +130,15 @@ - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
138130
[nodesManager startAnimatingNode:[NSNumber numberWithDouble:animationId] nodeTag:[NSNumber numberWithDouble:nodeTag] config:config endCallback:callBack];
139131
}];
140132

141-
BOOL isNodeManagedByFabric = [_nodeIDsManagedByFabric containsObject:@(nodeTag)];
142-
if (isNodeManagedByFabric) {
143-
self->_animIdIsManagedByFabric[[NSNumber numberWithDouble:animationId]] = @YES;
144-
[self flushOperationQueues];
145-
}
133+
[self flushOperationQueues];
146134
}
147135

148136
RCT_EXPORT_METHOD(stopAnimation:(double)animationId)
149137
{
150138
[self addOperationBlock:^(RCTNativeAnimatedNodesManager *nodesManager) {
151139
[nodesManager stopAnimation:[NSNumber numberWithDouble:animationId]];
152140
}];
153-
if ([_animIdIsManagedByFabric[[NSNumber numberWithDouble:animationId]] boolValue]) {
154-
[self flushOperationQueues];
155-
}
141+
[self flushOperationQueues];
156142
}
157143

158144
RCT_EXPORT_METHOD(setAnimatedNodeValue:(double)nodeTag
@@ -192,9 +178,6 @@ - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
192178
RCT_EXPORT_METHOD(connectAnimatedNodeToView:(double)nodeTag
193179
viewTag:(double)viewTag)
194180
{
195-
if (RCTUIManagerTypeForTagIsFabric(@(viewTag))) {
196-
[_nodeIDsManagedByFabric addObject:@(nodeTag)];
197-
}
198181
[self addOperationBlock:^(RCTNativeAnimatedNodesManager *nodesManager) {
199182
// viewName is not used when node is managed by Fabric, and nodes are always managed by Fabric in Bridgeless.
200183
[nodesManager connectAnimatedNodeToView:[NSNumber numberWithDouble:nodeTag] viewTag:[NSNumber numberWithDouble:viewTag] viewName:nil];
@@ -296,7 +279,6 @@ - (void)flushOperationQueues
296279
_preOperations = [NSMutableArray new];
297280
_operations = [NSMutableArray new];
298281

299-
300282
RCTExecuteOnMainQueue(^{
301283
for (AnimatedOperation operation in preOperations) {
302284
operation(self->_nodesManager);

0 commit comments

Comments
 (0)