apple: fix timing issue crash in executeApplicationScript (#134)
* fix timing issue with _reactInstance going away between null check and call * Move comment
This commit is contained in:
Родитель
2c2ac65b90
Коммит
1b8721792e
|
@ -1302,19 +1302,21 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName:RCTJavaScriptWillStartExecutingNotification
|
postNotificationName:RCTJavaScriptWillStartExecutingNotification
|
||||||
object:self->_parentBridge userInfo:@{@"bridge": self}];
|
object:self->_parentBridge userInfo:@{@"bridge": self}];
|
||||||
|
// TODO(OSS Candidate ISS#2710739) - use local reactInstance, instance can be null'd while constructing NSDataBigString
|
||||||
|
auto reactInstance = self->_reactInstance;
|
||||||
if (isRAMBundle(script)) {
|
if (isRAMBundle(script)) {
|
||||||
[self->_performanceLogger markStartForTag:RCTPLRAMBundleLoad];
|
[self->_performanceLogger markStartForTag:RCTPLRAMBundleLoad];
|
||||||
auto ramBundle = std::make_unique<JSIndexedRAMBundle>(sourceUrlStr.UTF8String);
|
auto ramBundle = std::make_unique<JSIndexedRAMBundle>(sourceUrlStr.UTF8String);
|
||||||
std::unique_ptr<const JSBigString> scriptStr = ramBundle->getStartupCode();
|
std::unique_ptr<const JSBigString> scriptStr = ramBundle->getStartupCode();
|
||||||
[self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad];
|
[self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad];
|
||||||
[self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize];
|
[self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize];
|
||||||
if (self->_reactInstance) {
|
if (reactInstance) {
|
||||||
auto registry = RAMBundleRegistry::multipleBundlesRegistry(std::move(ramBundle), JSIndexedRAMBundle::buildFactory());
|
auto registry = RAMBundleRegistry::multipleBundlesRegistry(std::move(ramBundle), JSIndexedRAMBundle::buildFactory());
|
||||||
self->_reactInstance->loadRAMBundle(std::move(registry), std::move(scriptStr),
|
reactInstance->loadRAMBundle(std::move(registry), std::move(scriptStr),
|
||||||
sourceUrlStr.UTF8String, !async);
|
sourceUrlStr.UTF8String, !async);
|
||||||
}
|
}
|
||||||
} else if (self->_reactInstance) {
|
} else if (reactInstance) {
|
||||||
self->_reactInstance->loadScriptFromString(std::make_unique<NSDataBigString>(script), 0,
|
reactInstance->loadScriptFromString(std::make_unique<NSDataBigString>(script), 0,
|
||||||
sourceUrlStr.UTF8String, !async, ""); // TODO(OSS Candidate ISS#2710739)
|
sourceUrlStr.UTF8String, !async, ""); // TODO(OSS Candidate ISS#2710739)
|
||||||
} else {
|
} else {
|
||||||
std::string methodName = async ? "loadApplicationScript" : "loadApplicationScriptSync";
|
std::string methodName = async ? "loadApplicationScript" : "loadApplicationScriptSync";
|
||||||
|
|
Загрузка…
Ссылка в новой задаче