Revert "[ReactNative] Fix RCTJavaScriptContext deallocation"

This commit is contained in:
Natansh Verma 2015-07-08 00:28:54 -07:00
parent f21e79d5e1
commit 98521eb16e
2 changed files with 41 additions and 25 deletions

View File

@ -347,36 +347,53 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
RCTLatestExecutor = nil;
}
[_mainDisplayLink invalidate];
_mainDisplayLink = nil;
void (^mainThreadInvalidate)(void) = ^{
RCTAssertMainThread();
// Invalidate modules
dispatch_group_t group = dispatch_group_create();
for (RCTModuleData *moduleData in _modules) {
if (moduleData.instance == _javaScriptExecutor) {
continue;
}
[_mainDisplayLink invalidate];
_mainDisplayLink = nil;
if ([moduleData.instance respondsToSelector:@selector(invalidate)]) {
[moduleData dispatchBlock:^{
[(id<RCTInvalidating>)moduleData.instance invalidate];
} dispatchGroup:group];
// Invalidate modules
dispatch_group_t group = dispatch_group_create();
for (RCTModuleData *moduleData in _modules) {
if ([moduleData.instance respondsToSelector:@selector(invalidate)]) {
[moduleData dispatchBlock:^{
[(id<RCTInvalidating>)moduleData.instance invalidate];
} dispatchGroup:group];
}
moduleData.queue = nil;
}
moduleData.queue = nil;
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
_modules = nil;
_modulesByName = nil;
_frameUpdateObservers = nil;
});
};
if (!_javaScriptExecutor) {
// No JS thread running
mainThreadInvalidate();
return;
}
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
[_jsDisplayLink invalidate];
_jsDisplayLink = nil;
[_javaScriptExecutor invalidate];
_javaScriptExecutor = nil;
}];
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
_modules = nil;
_modulesByName = nil;
_frameUpdateObservers = nil;
});
/**
* JS Thread deallocations
*/
[_javaScriptExecutor invalidate];
_javaScriptExecutor = nil;
[_jsDisplayLink invalidate];
_jsDisplayLink = nil;
/**
* Main Thread deallocations
*/
dispatch_async(dispatch_get_main_queue(), mainThreadInvalidate);
}];
}
#pragma mark - RCTBridge methods

View File

@ -320,7 +320,6 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
onThread:_javaScriptThread
withObject:nil
waitUntilDone:NO];
_context = nil;
}
- (void)dealloc