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]
|
||||
postNotificationName:RCTJavaScriptWillStartExecutingNotification
|
||||
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)) {
|
||||
[self->_performanceLogger markStartForTag:RCTPLRAMBundleLoad];
|
||||
auto ramBundle = std::make_unique<JSIndexedRAMBundle>(sourceUrlStr.UTF8String);
|
||||
std::unique_ptr<const JSBigString> scriptStr = ramBundle->getStartupCode();
|
||||
[self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad];
|
||||
[self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize];
|
||||
if (self->_reactInstance) {
|
||||
if (reactInstance) {
|
||||
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);
|
||||
}
|
||||
} else if (self->_reactInstance) {
|
||||
self->_reactInstance->loadScriptFromString(std::make_unique<NSDataBigString>(script), 0,
|
||||
} else if (reactInstance) {
|
||||
reactInstance->loadScriptFromString(std::make_unique<NSDataBigString>(script), 0,
|
||||
sourceUrlStr.UTF8String, !async, ""); // TODO(OSS Candidate ISS#2710739)
|
||||
} else {
|
||||
std::string methodName = async ? "loadApplicationScript" : "loadApplicationScriptSync";
|
||||
|
|
Загрузка…
Ссылка в новой задаче