From 6fe69f773a79df237f201c9ffdc1ead2c47f2092 Mon Sep 17 00:00:00 2001 From: johnche Date: Fri, 7 Feb 2025 11:05:47 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[unreal]=E6=8B=B7=E8=B4=9D=E6=9E=84?= =?UTF-8?q?=E9=80=A0=E5=92=8C=E8=B5=8B=E5=80=BC=E9=87=8D=E8=BD=BD=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E7=94=A8Global.Get=E8=8E=B7=E5=8F=96Local=20Handle?= =?UTF-8?q?=E9=9C=80=E8=A6=81HandleScope=EF=BC=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E4=BC=A0Global?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unreal/Puerts/Source/JsEnv/Public/JsObject.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unreal/Puerts/Source/JsEnv/Public/JsObject.h b/unreal/Puerts/Source/JsEnv/Public/JsObject.h index 9d72976350b..b487f3304d5 100644 --- a/unreal/Puerts/Source/JsEnv/Public/JsObject.h +++ b/unreal/Puerts/Source/JsEnv/Public/JsObject.h @@ -49,8 +49,8 @@ struct FJsObject #ifdef THREAD_SAFE v8::Locker Locker(Isolate); #endif - GContext.Reset(Isolate, InOther.GContext.Get(Isolate)); - GObject.Reset(Isolate, InOther.GObject.Get(Isolate)); + GContext.Reset(Isolate, InOther.GContext); + GObject.Reset(Isolate, InOther.GObject); JsEnvLifeCycleTracker = PUERTS_NAMESPACE::DataTransfer::GetJsEnvLifeCycleTracker(Isolate); } @@ -96,8 +96,8 @@ struct FJsObject return *this; } Isolate = InOther.Isolate; - GContext.Reset(Isolate, InOther.GContext.Get(Isolate)); - GObject.Reset(Isolate, InOther.GObject.Get(Isolate)); + GContext.Reset(Isolate, InOther.GContext); + GObject.Reset(Isolate, InOther.GObject); JsEnvLifeCycleTracker = PUERTS_NAMESPACE::DataTransfer::GetJsEnvLifeCycleTracker(Isolate); return *this; } From 467e3a056b176e7a53bd4e436ace61740bac2677 Mon Sep 17 00:00:00 2001 From: johnche Date: Fri, 7 Feb 2025 11:15:22 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[unreal]=E4=B8=8A=E4=B8=AA=E6=94=B9?= =?UTF-8?q?=E6=B3=95=E7=94=A8=E5=88=B0=E7=9A=84v8=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=9C=A8quickjs=20backend=E6=B2=A1=E6=9C=89=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E4=B8=BA=E5=8F=A6=E5=A4=96=E4=B8=80=E7=A7=8D?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unreal/Puerts/Source/JsEnv/Public/JsObject.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/unreal/Puerts/Source/JsEnv/Public/JsObject.h b/unreal/Puerts/Source/JsEnv/Public/JsObject.h index b487f3304d5..8d1b890ad69 100644 --- a/unreal/Puerts/Source/JsEnv/Public/JsObject.h +++ b/unreal/Puerts/Source/JsEnv/Public/JsObject.h @@ -49,8 +49,10 @@ struct FJsObject #ifdef THREAD_SAFE v8::Locker Locker(Isolate); #endif - GContext.Reset(Isolate, InOther.GContext); - GObject.Reset(Isolate, InOther.GObject); + v8::Isolate::Scope IsolateScope(Isolate); + v8::HandleScope HandleScope(Isolate); + GContext.Reset(Isolate, InOther.GContext.Get(Isolate)); + GObject.Reset(Isolate, InOther.GObject.Get(Isolate)); JsEnvLifeCycleTracker = PUERTS_NAMESPACE::DataTransfer::GetJsEnvLifeCycleTracker(Isolate); } @@ -96,8 +98,10 @@ struct FJsObject return *this; } Isolate = InOther.Isolate; - GContext.Reset(Isolate, InOther.GContext); - GObject.Reset(Isolate, InOther.GObject); + v8::Isolate::Scope IsolateScope(Isolate); + v8::HandleScope HandleScope(Isolate); + GContext.Reset(Isolate, InOther.GContext.Get(Isolate)); + GObject.Reset(Isolate, InOther.GObject.Get(Isolate)); JsEnvLifeCycleTracker = PUERTS_NAMESPACE::DataTransfer::GetJsEnvLifeCycleTracker(Isolate); return *this; } From 69ea454e3099187e14b713e49ef2fd0131223caa Mon Sep 17 00:00:00 2001 From: johnche Date: Mon, 10 Feb 2025 11:47:08 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[unity]osx=E7=BC=96=E8=AF=91=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../upm/Editor/Resources/puerts/xil2cpp/Puerts_il2cpp.cpp.txt | 2 +- .../core/upm/Editor/Resources/puerts/xil2cpp/TDataTrans.h.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/Puerts_il2cpp.cpp.txt b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/Puerts_il2cpp.cpp.txt index 861ad17b5be..b31775f7f41 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/Puerts_il2cpp.cpp.txt +++ b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/Puerts_il2cpp.cpp.txt @@ -2223,7 +2223,7 @@ struct JsEnvPrivate pesapi_env_ref envRef; std::mutex pendingKillRefsMutex; std::unordered_set pendingKillRefs; - std::unordered_set, std::equal_to, il2cpp::gc::Allocator> objectPool; + std::unordered_set, std::equal_to, il2cpp::gc::Allocator> objectPool; JsEnvPrivate(struct pesapi_ffi* inApis, pesapi_env_ref inEnvRef) : apis(inApis), envRef(inEnvRef) diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/TDataTrans.h.txt b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/TDataTrans.h.txt index fc9a7f5ced6..317b36670e6 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/TDataTrans.h.txt +++ b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/TDataTrans.h.txt @@ -545,7 +545,7 @@ struct MethodInfoHelper { }; -Il2CppMethodPointer GetMethodPointer(const MethodInfo* method); +static Il2CppMethodPointer GetMethodPointer(const MethodInfo* method); template struct MethodInfoHelper<_Ret (_Args...)> From 0ea3ade8e05eac8c2d028f56984e5f7ae2192492 Mon Sep 17 00:00:00 2001 From: bingcongni Date: Fri, 14 Feb 2025 14:25:13 +0800 Subject: [PATCH 4/4] [unity] fix crash on ios (cherry picked from commit 1e8276937a1b0955950ab09b057e77e7e2a77ea0) --- unity/native_src/Src/JSEngine.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unity/native_src/Src/JSEngine.cpp b/unity/native_src/Src/JSEngine.cpp index d1088205697..3ac1abcd282 100644 --- a/unity/native_src/Src/JSEngine.cpp +++ b/unity/native_src/Src/JSEngine.cpp @@ -210,6 +210,12 @@ namespace PUERTS_NAMESPACE #ifdef WITH_IL2CPP_OPTIMIZATION CppObjectMapper.UnInitialize(MainIsolate); #endif + + for (int i = 0; i < CallbackWithFinalizeInfos.size(); ++i) + { + CallbackWithFinalizeInfos[i]->JsFunction.Reset(); + } + BackendEnv.UnInitialize(); for (int i = 0; i < CallbackInfos.size(); ++i)