[ReactNative] Invalidate modules on their own queues
Summary: @public Bridge modules were being invalidate on the main thread, what could lead to racing conditions, move the calls to invalidate on happen to the module's methodQueue Test Plan: Run the tests
This commit is contained in:
parent
35b770201d
commit
1c9e957d22
|
@ -1111,7 +1111,9 @@ RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(NSString *)module method:(NSStrin
|
||||||
// Invalidate modules
|
// Invalidate modules
|
||||||
for (id target in _modulesByID.allObjects) {
|
for (id target in _modulesByID.allObjects) {
|
||||||
if ([target respondsToSelector:@selector(invalidate)]) {
|
if ([target respondsToSelector:@selector(invalidate)]) {
|
||||||
[(id<RCTInvalidating>)target invalidate];
|
[self dispatchBlock:^{
|
||||||
|
[(id<RCTInvalidating>)target invalidate];
|
||||||
|
} forModule:target];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -342,14 +342,19 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewNa
|
||||||
CGRect frame = rootView.frame;
|
CGRect frame = rootView.frame;
|
||||||
|
|
||||||
// Register shadow view
|
// Register shadow view
|
||||||
|
__weak RCTUIManager *weakSelf = self;
|
||||||
dispatch_async(_shadowQueue, ^{
|
dispatch_async(_shadowQueue, ^{
|
||||||
|
RCTUIManager *strongSelf = weakSelf;
|
||||||
|
if (!strongSelf.isValid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
RCTShadowView *shadowView = [[RCTShadowView alloc] init];
|
RCTShadowView *shadowView = [[RCTShadowView alloc] init];
|
||||||
shadowView.reactTag = reactTag;
|
shadowView.reactTag = reactTag;
|
||||||
shadowView.frame = frame;
|
shadowView.frame = frame;
|
||||||
shadowView.backgroundColor = rootView.backgroundColor;
|
shadowView.backgroundColor = rootView.backgroundColor;
|
||||||
shadowView.viewName = NSStringFromClass([rootView class]);
|
shadowView.viewName = NSStringFromClass([rootView class]);
|
||||||
_shadowViewRegistry[shadowView.reactTag] = shadowView;
|
strongSelf->_shadowViewRegistry[shadowView.reactTag] = shadowView;
|
||||||
[_rootViewTags addObject:reactTag];
|
[strongSelf->_rootViewTags addObject:reactTag];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue