diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 8b3b13b..2bba959 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -12,9 +12,12 @@ jobs: runs-on: macos-10.15 strategy: matrix: - rn-version: [0.69, 0.68] + rn-version: ['0.70', '0.69'] v8-android-variant: [v8-android-jit, v8-android-jit-nointl, v8-android, v8-android-nointl] + include: + - rn-version: '0.68' + v8-android-variant: v8-android-jit steps: - uses: actions/checkout@v2 diff --git a/android/src/main/cpp/V8ExecutorFactory.cpp b/android/src/main/cpp/V8ExecutorFactory.cpp index c55e2e5..138f2ac 100644 --- a/android/src/main/cpp/V8ExecutorFactory.cpp +++ b/android/src/main/cpp/V8ExecutorFactory.cpp @@ -22,7 +22,7 @@ namespace rnv8 { namespace { std::unique_ptr makeV8RuntimeSystraced( - std::unique_ptr config, + std::unique_ptr config, std::shared_ptr jsQueue) { react::SystraceSection s("V8ExecutorFactory::makeV8RuntimeSystraced"); return createV8Runtime(std::move(config), jsQueue); diff --git a/scripts/lib/patcher.py b/scripts/lib/patcher.py index 8e8e090..7ea46ed 100644 --- a/scripts/lib/patcher.py +++ b/scripts/lib/patcher.py @@ -72,6 +72,7 @@ def _patch_app_gradle(self): with io.open(app_gradle_path, "r", encoding="utf8") as f: content = str(f.read()) new_content = self._get_patched_packging_option(content) + new_content = new_content.replace("enableHermes: true", "enableHermes: false") with io.open(app_gradle_path, "w", encoding="utf8") as f: f.write(new_content) diff --git a/src/v8runtime/V8Inspector.cpp b/src/v8runtime/V8Inspector.cpp index 3ea3144..891eb6b 100644 --- a/src/v8runtime/V8Inspector.cpp +++ b/src/v8runtime/V8Inspector.cpp @@ -138,7 +138,7 @@ InspectorClient::InspectorClient( v8::Local context, const std::string &appName, const std::string &deviceName) { - jsQueue_ = jsQueue; + jsQueue_ = jsQueue; isolate_ = context->GetIsolate(); v8::HandleScope scopedHandle(isolate_); channel_.reset(new InspectorFrontend(this, context)); @@ -246,15 +246,16 @@ void InspectorClient::DispatchProxy(const std::string &message) { auto messageObj = folly::parseJson(message); auto method = messageObj["method"].asString(); - // For `v8::CpuProfiler` or some other modules with thread local storage, we should dispatch messages in the js thread. + // For `v8::CpuProfiler` or some other modules with thread local storage, we + // should dispatch messages in the js thread. if (method == "Profiler.start" || method == "Profiler.stop") { jsQueue_->runOnQueue([this, normalizedString]() { - v8::Isolate *isolate = GetIsolate(); - v8::Locker locker(isolate); - v8::Isolate::Scope scopedIsolate(isolate); - v8::HandleScope scopedHandle(isolate); - v8::Context::Scope scopedContext(GetContext().Get(isolate)); - session_->dispatchProtocolMessage(ToStringView(normalizedString)); + v8::Isolate *isolate = GetIsolate(); + v8::Locker locker(isolate); + v8::Isolate::Scope scopedIsolate(isolate); + v8::HandleScope scopedHandle(isolate); + v8::Context::Scope scopedContext(GetContext().Get(isolate)); + session_->dispatchProtocolMessage(ToStringView(normalizedString)); }); return; } diff --git a/src/v8runtime/V8Inspector.h b/src/v8runtime/V8Inspector.h index a9fc2be..7eeb2f1 100644 --- a/src/v8runtime/V8Inspector.h +++ b/src/v8runtime/V8Inspector.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include "jsinspector/InspectorInterfaces.h" #include "v8-inspector.h" diff --git a/src/v8runtime/V8Runtime.cpp b/src/v8runtime/V8Runtime.cpp index 2c23c9a..b26a9e1 100644 --- a/src/v8runtime/V8Runtime.cpp +++ b/src/v8runtime/V8Runtime.cpp @@ -30,8 +30,9 @@ const char kHostFunctionProxyProp[] = "__hostFunctionProxy"; std::unique_ptr V8Runtime::s_platform = nullptr; std::mutex s_platform_mutex; // protects s_platform -V8Runtime::V8Runtime(std::unique_ptr config, -std::shared_ptr jsQueue) +V8Runtime::V8Runtime( + std::unique_ptr config, + std::shared_ptr jsQueue) : config_(std::move(config)) { { const std::lock_guard lock(s_platform_mutex); @@ -70,7 +71,10 @@ std::shared_ptr jsQueue) jsQueue_ = jsQueue; if (config_->enableInspector) { inspectorClient_ = std::make_shared( - jsQueue_, context_.Get(isolate_), config_->appName, config_->deviceName); + jsQueue_, + context_.Get(isolate_), + config_->appName, + config_->deviceName); inspectorClient_->ConnectToReactFrontend(); } } @@ -108,7 +112,10 @@ V8Runtime::V8Runtime( if (config_->enableInspector) { inspectorClient_ = std::make_shared( - jsQueue_, context_.Get(isolate_), config_->appName, config_->deviceName); + jsQueue_, + context_.Get(isolate_), + config_->appName, + config_->deviceName); inspectorClient_->ConnectToReactFrontend(); } } @@ -486,6 +493,25 @@ jsi::Runtime::PointerValue *V8Runtime::cloneSymbol( return new V8PointerValue(isolate_, v8PointerValue->Get(isolate_)); } +#if REACT_NATIVE_TARGET_VERSION >= 70 +jsi::Runtime::PointerValue *V8Runtime::cloneBigInt( + const Runtime::PointerValue *pv) { + if (!pv) { + return nullptr; + } + + v8::Locker locker(isolate_); + v8::Isolate::Scope scopedIsolate(isolate_); + v8::HandleScope scopedHandle(isolate_); + v8::Context::Scope scopedContext(context_.Get(isolate_)); + + const V8PointerValue *v8PointerValue = + static_cast(pv); + assert(v8PointerValue->Get(isolate_)->IsBigInt()); + return new V8PointerValue(isolate_, v8PointerValue->Get(isolate_)); +} +#endif + jsi::Runtime::PointerValue *V8Runtime::cloneString( const Runtime::PointerValue *pv) { if (!pv) { @@ -1244,6 +1270,27 @@ bool V8Runtime::strictEquals(const jsi::Symbol &a, const jsi::Symbol &b) const { return result; } +#if REACT_NATIVE_TARGET_VERSION >= 70 +bool V8Runtime::strictEquals(const jsi::BigInt &a, const jsi::BigInt &b) const { + v8::Locker locker(isolate_); + v8::Isolate::Scope scopedIsolate(isolate_); + v8::HandleScope scopedHandle(isolate_); + v8::Context::Scope scopedContext(context_.Get(isolate_)); + + v8::TryCatch tryCatch(isolate_); + v8::Local v8ValueA = + (static_cast(getPointerValue(a)))->Get(isolate_); + v8::Local v8ValueB = + (static_cast(getPointerValue(b)))->Get(isolate_); + bool result = v8ValueA->StrictEquals(v8ValueB); + + if (tryCatch.HasCaught()) { + ReportException(isolate_, &tryCatch); + } + return result; +} +#endif + bool V8Runtime::strictEquals(const jsi::String &a, const jsi::String &b) const { v8::Locker locker(isolate_); v8::Isolate::Scope scopedIsolate(isolate_); diff --git a/src/v8runtime/V8Runtime.h b/src/v8runtime/V8Runtime.h index 5e9d0ce..18b65b3 100644 --- a/src/v8runtime/V8Runtime.h +++ b/src/v8runtime/V8Runtime.h @@ -21,8 +21,9 @@ class InspectorClient; class V8Runtime : public facebook::jsi::Runtime { public: - V8Runtime(std::unique_ptr config, - std::shared_ptr jsQueue); + V8Runtime( + std::unique_ptr config, + std::shared_ptr jsQueue); V8Runtime( const V8Runtime *v8Runtime, std::unique_ptr config); @@ -73,6 +74,9 @@ class V8Runtime : public facebook::jsi::Runtime { protected: PointerValue *cloneSymbol(const Runtime::PointerValue *pv) override; +#if REACT_NATIVE_TARGET_VERSION >= 70 + PointerValue *cloneBigInt(const Runtime::PointerValue *pv) override; +#endif PointerValue *cloneString(const Runtime::PointerValue *pv) override; PointerValue *cloneObject(const Runtime::PointerValue *pv) override; PointerValue *clonePropNameID(const Runtime::PointerValue *pv) override; @@ -170,6 +174,11 @@ class V8Runtime : public facebook::jsi::Runtime { bool strictEquals( const facebook::jsi::Symbol &a, const facebook::jsi::Symbol &b) const override; +#if REACT_NATIVE_TARGET_VERSION >= 70 + bool strictEquals( + const facebook::jsi::BigInt &a, + const facebook::jsi::BigInt &b) const override; +#endif bool strictEquals( const facebook::jsi::String &a, const facebook::jsi::String &b) const override; diff --git a/src/v8runtime/V8RuntimeFactory.h b/src/v8runtime/V8RuntimeFactory.h index 5a0850d..972b27b 100644 --- a/src/v8runtime/V8RuntimeFactory.h +++ b/src/v8runtime/V8RuntimeFactory.h @@ -7,15 +7,16 @@ #pragma once +#include #include #include "V8RuntimeConfig.h" #include "jsi/jsi.h" -#include namespace rnv8 { std::unique_ptr createV8Runtime( - std::unique_ptr config, std::shared_ptr jsQueue); + std::unique_ptr config, + std::shared_ptr jsQueue); std::unique_ptr createSharedV8Runtime( const facebook::jsi::Runtime *sharedRuntime,