Don't create the JSCRuntime until createJSExecutor() is called.
Summary: This avoids an intermittent reentrancy bug in JSC on iOS 11 (https://bugs.webkit.org/show_bug.cgi?id=186827). It also makes the code more consistent with android. Reviewed By: amnn Differential Revision: D13313265 fbshipit-source-id: f42476b2f660e127ecfc9c72584554817eea1010
This commit is contained in:
parent
bdb084e8a8
commit
99c370959a
|
@ -56,7 +56,6 @@ static NSString *const RCTJSThreadName = @"com.facebook.react.JavaScript";
|
|||
|
||||
typedef void (^RCTPendingCall)();
|
||||
|
||||
using namespace facebook::jsc;
|
||||
using namespace facebook::jsi;
|
||||
using namespace facebook::react;
|
||||
|
||||
|
@ -92,6 +91,24 @@ private:
|
|||
std::shared_ptr<JSExecutorFactory> factory_;
|
||||
};
|
||||
|
||||
class JSCExecutorFactory : public JSExecutorFactory {
|
||||
public:
|
||||
std::unique_ptr<JSExecutor> createJSExecutor(
|
||||
std::shared_ptr<ExecutorDelegate> delegate,
|
||||
std::shared_ptr<MessageQueueThread> jsQueue) override {
|
||||
return folly::make_unique<JSIExecutor>(
|
||||
facebook::jsc::makeJSCRuntime(),
|
||||
delegate,
|
||||
[](const std::string &message, unsigned int logLevel) {
|
||||
_RCTLogJavaScriptInternal(
|
||||
static_cast<RCTLogLevel>(logLevel),
|
||||
[NSString stringWithUTF8String:message.c_str()]);
|
||||
},
|
||||
JSIExecutor::defaultTimeoutInvoker,
|
||||
nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static bool isRAMBundle(NSData *script) {
|
||||
|
@ -320,13 +337,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|||
executorFactory = [cxxDelegate jsExecutorFactoryForBridge:self];
|
||||
}
|
||||
if (!executorFactory) {
|
||||
executorFactory = std::make_shared<JSIExecutorFactory>(
|
||||
makeJSCRuntime(),
|
||||
[](const std::string &message, unsigned int logLevel) {
|
||||
_RCTLogJavaScriptInternal(
|
||||
static_cast<RCTLogLevel>(logLevel),
|
||||
[NSString stringWithUTF8String:message.c_str()]);
|
||||
}, nullptr);
|
||||
executorFactory = std::make_shared<JSCExecutorFactory>();
|
||||
}
|
||||
} else {
|
||||
id<RCTJavaScriptExecutor> objcExecutor = [self moduleForClass:self.executorClass];
|
||||
|
|
Loading…
Reference in New Issue