[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:
Tadeu Zagallo 2015-06-06 14:12:37 -07:00
parent 35b770201d
commit 1c9e957d22
2 changed files with 10 additions and 3 deletions

View File

@ -1111,7 +1111,9 @@ RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(NSString *)module method:(NSStrin
// Invalidate modules
for (id target in _modulesByID.allObjects) {
if ([target respondsToSelector:@selector(invalidate)]) {
[(id<RCTInvalidating>)target invalidate];
[self dispatchBlock:^{
[(id<RCTInvalidating>)target invalidate];
} forModule:target];
}
}

View File

@ -342,14 +342,19 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewNa
CGRect frame = rootView.frame;
// Register shadow view
__weak RCTUIManager *weakSelf = self;
dispatch_async(_shadowQueue, ^{
RCTUIManager *strongSelf = weakSelf;
if (!strongSelf.isValid) {
return;
}
RCTShadowView *shadowView = [[RCTShadowView alloc] init];
shadowView.reactTag = reactTag;
shadowView.frame = frame;
shadowView.backgroundColor = rootView.backgroundColor;
shadowView.viewName = NSStringFromClass([rootView class]);
_shadowViewRegistry[shadowView.reactTag] = shadowView;
[_rootViewTags addObject:reactTag];
strongSelf->_shadowViewRegistry[shadowView.reactTag] = shadowView;
[strongSelf->_rootViewTags addObject:reactTag];
});
}