1 #include "ReanimatedRuntime.h" 2 3 #include <cxxreact/MessageQueueThread.h> 4 #include <jsi/jsi.h> 5 6 #include <memory> 7 #include <utility> 8 9 #if JS_RUNTIME_HERMES 10 #include "ReanimatedHermesRuntime.h" 11 #elif JS_RUNTIME_V8 12 #include <v8runtime/V8RuntimeFactory.h> 13 #else 14 #if REACT_NATIVE_MINOR_VERSION >= 71 15 #include <jsc/JSCRuntime.h> 16 #else 17 #include <jsi/JSCRuntime.h> 18 #endif // REACT_NATIVE_MINOR_VERSION 19 #endif // JS_RUNTIME 20 21 namespace reanimated { 22 23 using namespace facebook; 24 using namespace react; 25 26 std::shared_ptr<jsi::Runtime> ReanimatedRuntime::make( 27 jsi::Runtime *rnRuntime, 28 std::shared_ptr<MessageQueueThread> jsQueue) { 29 #if JS_RUNTIME_HERMES 30 std::unique_ptr<facebook::hermes::HermesRuntime> runtime = 31 facebook::hermes::makeHermesRuntime(); 32 33 // We don't call `jsQueue->quitSynchronous()` here, since it will be done 34 // later in ReanimatedHermesRuntime 35 36 return std::make_shared<ReanimatedHermesRuntime>(std::move(runtime), jsQueue); 37 #elif JS_RUNTIME_V8 38 // This is required by iOS, because there is an assertion in the destructor 39 // that the thread was indeed `quit` before. 40 jsQueue->quitSynchronous(); 41 42 auto config = std::make_unique<rnv8::V8RuntimeConfig>(); 43 config->enableInspector = false; 44 config->appName = "reanimated"; 45 return rnv8::createSharedV8Runtime(rnRuntime, std::move(config)); 46 #else 47 // This is required by iOS, because there is an assertion in the destructor 48 // that the thread was indeed `quit` before 49 jsQueue->quitSynchronous(); 50 51 return facebook::jsc::makeJSCRuntime(); 52 #endif 53 } 54 55 } // namespace reanimated 56