mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: The second attempt to fix a thread-safety issue in RCTNativeAnimatedModule
Summary: Previously we tried to fix that with RCTUnsafeExecuteOnUIManagerQueueSync but that caused a deadlock (yeah, it's actually unsafe). Besides that, I tried to solve that with introducing a mutex that covers access to `_operations` and `_preOperations` but failed miserably. It solved threading issue but that didn't fix data-races and inconsistency of the collections. Reviewed By: sahrens Differential Revision: D15587564 fbshipit-source-id: d1953036b09354d1663a9b191440f8b4a4e6be9d
This commit is contained in:
committed by
Facebook Github Bot
parent
5a8cdb4bb7
commit
a2913d33a6
@@ -232,27 +232,31 @@ RCT_EXPORT_METHOD(removeAnimatedEventFromView:(nonnull NSNumber *)viewTag
|
||||
- (void)willMountComponentsWithRootTag:(NSInteger)rootTag
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
__block NSArray<AnimatedOperation> *preOperations;
|
||||
RCTUnsafeExecuteOnUIManagerQueueSync(^{
|
||||
preOperations = self->_preOperations;
|
||||
RCTExecuteOnUIManagerQueue(^{
|
||||
NSArray<AnimatedOperation> *preOperations = self->_preOperations;
|
||||
self->_preOperations = [NSMutableArray new];
|
||||
|
||||
RCTExecuteOnMainQueue(^{
|
||||
for (AnimatedOperation preOperation in preOperations) {
|
||||
preOperation(self->_nodesManager);
|
||||
}
|
||||
});
|
||||
});
|
||||
for (AnimatedOperation operation in preOperations) {
|
||||
operation(self->_nodesManager);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didMountComponentsWithRootTag:(NSInteger)rootTag
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
__block NSArray<AnimatedOperation> *operations;
|
||||
RCTUnsafeExecuteOnUIManagerQueueSync(^{
|
||||
operations = self->_operations;
|
||||
RCTExecuteOnUIManagerQueue(^{
|
||||
NSArray<AnimatedOperation> *operations = self->_operations;
|
||||
self->_operations = [NSMutableArray new];
|
||||
|
||||
RCTExecuteOnMainQueue(^{
|
||||
for (AnimatedOperation operation in operations) {
|
||||
operation(self->_nodesManager);
|
||||
}
|
||||
});
|
||||
});
|
||||
for (AnimatedOperation operation in operations) {
|
||||
operation(self->_nodesManager);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - RCTUIManagerObserver
|
||||
|
||||
Reference in New Issue
Block a user