Revert "[ReactNative] Fix RCTJavaScriptContext deallocation"
This commit is contained in:
parent
f21e79d5e1
commit
98521eb16e
|
@ -347,16 +347,15 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
|
||||||
RCTLatestExecutor = nil;
|
RCTLatestExecutor = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void (^mainThreadInvalidate)(void) = ^{
|
||||||
|
RCTAssertMainThread();
|
||||||
|
|
||||||
[_mainDisplayLink invalidate];
|
[_mainDisplayLink invalidate];
|
||||||
_mainDisplayLink = nil;
|
_mainDisplayLink = nil;
|
||||||
|
|
||||||
// Invalidate modules
|
// Invalidate modules
|
||||||
dispatch_group_t group = dispatch_group_create();
|
dispatch_group_t group = dispatch_group_create();
|
||||||
for (RCTModuleData *moduleData in _modules) {
|
for (RCTModuleData *moduleData in _modules) {
|
||||||
if (moduleData.instance == _javaScriptExecutor) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([moduleData.instance respondsToSelector:@selector(invalidate)]) {
|
if ([moduleData.instance respondsToSelector:@selector(invalidate)]) {
|
||||||
[moduleData dispatchBlock:^{
|
[moduleData dispatchBlock:^{
|
||||||
[(id<RCTInvalidating>)moduleData.instance invalidate];
|
[(id<RCTInvalidating>)moduleData.instance invalidate];
|
||||||
|
@ -365,18 +364,36 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
|
||||||
moduleData.queue = nil;
|
moduleData.queue = nil;
|
||||||
}
|
}
|
||||||
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
|
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
|
||||||
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
||||||
[_jsDisplayLink invalidate];
|
|
||||||
_jsDisplayLink = nil;
|
|
||||||
|
|
||||||
[_javaScriptExecutor invalidate];
|
|
||||||
_javaScriptExecutor = nil;
|
|
||||||
}];
|
|
||||||
|
|
||||||
_modules = nil;
|
_modules = nil;
|
||||||
_modulesByName = nil;
|
_modulesByName = nil;
|
||||||
_frameUpdateObservers = nil;
|
_frameUpdateObservers = nil;
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!_javaScriptExecutor) {
|
||||||
|
|
||||||
|
// No JS thread running
|
||||||
|
mainThreadInvalidate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
#pragma mark - RCTBridge methods
|
||||||
|
|
|
@ -320,7 +320,6 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
|
||||||
onThread:_javaScriptThread
|
onThread:_javaScriptThread
|
||||||
withObject:nil
|
withObject:nil
|
||||||
waitUntilDone:NO];
|
waitUntilDone:NO];
|
||||||
_context = nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
|
|
Loading…
Reference in New Issue