diff --git a/native_engine/impl/ark/ark_native_engine.cpp b/native_engine/impl/ark/ark_native_engine.cpp index f242e1a5bc422e59cae4bce867b33ab33c357e92..6a482efef3ac29eec6435d8b6c37e7e312f1cf25 100644 --- a/native_engine/impl/ark/ark_native_engine.cpp +++ b/native_engine/impl/ark/ark_native_engine.cpp @@ -368,7 +368,7 @@ ArkNativeEngine::ArkNativeEngine(EcmaVM* vm, void* jsEngine, bool isLimitedWorke void* requireData = static_cast(this); options_ = new NapiOptions(); - crossThreadCheck_ = JSNApi::IsMultiThreadCheckEnabled(vm); + SetCrossThreadCheckStatus(JSNApi::IsMultiThreadCheckEnabled(vm)); #if defined(OHOS_PLATFORM) && !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM) int napiProperties = OHOS::system::GetIntParameter("persist.ark.napi.properties", -1); if (options_ != nullptr) { diff --git a/native_engine/impl/ark/ark_native_engine.h b/native_engine/impl/ark/ark_native_engine.h index a4af4db26528cd7a011e00c8a3661e7f633f4edf..11483612a9f80c0e3b766dec0f54b7b0392e0fbe 100644 --- a/native_engine/impl/ark/ark_native_engine.h +++ b/native_engine/impl/ark/ark_native_engine.h @@ -369,6 +369,10 @@ public: { return crossThreadCheck_; } + inline void SetCrossThreadCheckStatus(bool status) override + { + crossThreadCheck_ = status; + } static constexpr size_t FINALIZERS_PACK_PENDING_NATIVE_BINDING_SIZE_THRESHOLD = 500 * 1024 * 1024; // 500 MB private: diff --git a/native_engine/native_engine.cpp b/native_engine/native_engine.cpp index 321ad81f8e4dfe47cccb6e43af5a67b6307704d9..091c0796d7d1592702a64a67dce84af56b3800a5 100644 --- a/native_engine/native_engine.cpp +++ b/native_engine/native_engine.cpp @@ -249,6 +249,7 @@ bool NativeEngine::ReinitUVLoop() tid_ = pthread_self(); sysTid_ = GetCurSysTid(); + SetCrossThreadCheckStatus(JSNApi::IsMultiThreadCheckEnabled(vm)); loop_ = new (std::nothrow)uv_loop_t; if (loop_ == nullptr) { diff --git a/native_engine/native_engine.h b/native_engine/native_engine.h index 943f52f9bfaaeb4f6238fd307887c91270b16326..268d65b7414522f7edd3860fa4f501794a4e7b79 100644 --- a/native_engine/native_engine.h +++ b/native_engine/native_engine.h @@ -470,6 +470,7 @@ public: napi_status SendEvent(const std::function &cb, napi_event_priority priority = napi_eprio_high); virtual bool IsCrossThreadCheckEnabled() const = 0; + virtual void SetCrossThreadCheckStatus(bool status) = 0; bool IsInDestructor() const {