Animations: attempt to mitigate crashes in T43628589

Summary: Trying to mitigate animation-related crashes in T43628589. Clues: all the crashes are off the main thread, and most operations in this class happen explicitly in blocks executed on the main thread. I think there's a category of race conditions caused by animations not being allocated yet when this code runs / being deallocated as it's running. We shouldn't need to add locks if everything just runs on the main thread.

Reviewed By: PeteTheHeat

Differential Revision: D15924310

fbshipit-source-id: d82f5434e53fd394c4a7548d52f59a0f63961779
This commit is contained in:
Joshua Gross
2019-06-20 15:00:21 -07:00
committed by Facebook Github Bot
parent 2a4882e7e9
commit 40043a175e
2 changed files with 12 additions and 5 deletions
@@ -87,10 +87,14 @@ RCT_EXPORT_METHOD(startAnimatingNode:(nonnull NSNumber *)animationId
[self addOperationBlock:^(RCTNativeAnimatedNodesManager *nodesManager) {
[nodesManager startAnimatingNode:animationId nodeTag:nodeTag config:config endCallback:callBack];
}];
if ([_nodesManager isNodeManagedByFabric:nodeTag]) {
_animIdIsManagedByFabric[animationId] = @YES;
[self flushOperationQueues];
}
__weak RCTNativeAnimatedModule *weakSelf = self;
RCTExecuteOnMainQueue(^{
__strong RCTNativeAnimatedModule *strongSelf = weakSelf;
if (strongSelf && [strongSelf->_nodesManager isNodeManagedByFabric:nodeTag]) {
strongSelf->_animIdIsManagedByFabric[animationId] = @YES;
[strongSelf flushOperationQueues];
}
});
}
RCT_EXPORT_METHOD(stopAnimation:(nonnull NSNumber *)animationId)