From b4136c85b63e0bdae8e563f8b0c06726ca69e2c0 Mon Sep 17 00:00:00 2001 From: Pratik Chavan Date: Fri, 16 Jun 2023 15:00:15 +0530 Subject: [PATCH 1/5] can build project and package for windows with inspector working in editor --- .../Private/JavascriptCommandExecutor.cpp | 5 ++++- .../JavascriptWebSocket.Build.cs | 8 ++++---- Source/V8/Private/Inspector.cpp | 7 +++++++ Source/V8/Private/JavascriptContext_Private.cpp | 14 +++++++++----- Source/V8/V8.Build.cs | 8 ++++---- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Source/JavascriptConsole/Private/JavascriptCommandExecutor.cpp b/Source/JavascriptConsole/Private/JavascriptCommandExecutor.cpp index b361aa7f..2e18fd39 100644 --- a/Source/JavascriptConsole/Private/JavascriptCommandExecutor.cpp +++ b/Source/JavascriptConsole/Private/JavascriptCommandExecutor.cpp @@ -112,7 +112,10 @@ bool FJavascriptCommandExecutor::CacheJavascriptContext() { // Use Editor context only const auto JavascriptContext = IJavascriptEditorModule::Get().GetJavascriptContext(); - TargetContext = JavascriptContext->ContextId; + if (JavascriptContext) + { + TargetContext = JavascriptContext->ContextId; + } } if (TargetContext.IsValid()) diff --git a/Source/JavascriptWebSocket/JavascriptWebSocket.Build.cs b/Source/JavascriptWebSocket/JavascriptWebSocket.Build.cs index d8671e50..3a8f55b4 100644 --- a/Source/JavascriptWebSocket/JavascriptWebSocket.Build.cs +++ b/Source/JavascriptWebSocket/JavascriptWebSocket.Build.cs @@ -46,10 +46,10 @@ private void HackWebSocketIncludeDir(String WebsocketPath, ReadOnlyTargetRules T bHasZlib = true; } - else if (Target.Platform == UnrealTargetPlatform.Linux) - { - PlatformSubdir = Path.Combine(PlatformSubdir, Target.Architecture); - } + // else if (Target.Platform == UnrealTargetPlatform.Linux) + // { + // PlatformSubdir = Path.Combine(PlatformSubdir, Target.Architecture); + // } PrivateDependencyModuleNames.Add("libWebSockets"); diff --git a/Source/V8/Private/Inspector.cpp b/Source/V8/Private/Inspector.cpp index 7f9ee4a3..9f7a76f8 100644 --- a/Source/V8/Private/Inspector.cpp +++ b/Source/V8/Private/Inspector.cpp @@ -473,6 +473,13 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi { static FName NAME_Javascript("Javascript"); + /* + * Crash at if (!maybe_console.IsEmpty()) + * when inspector is enabled! + */ + return; + + if (Category != NAME_Javascript) { HandleScope handle_scope(isolate_); diff --git a/Source/V8/Private/JavascriptContext_Private.cpp b/Source/V8/Private/JavascriptContext_Private.cpp index 6912005b..59dc6b74 100644 --- a/Source/V8/Private/JavascriptContext_Private.cpp +++ b/Source/V8/Private/JavascriptContext_Private.cpp @@ -31,6 +31,7 @@ #include "../../Launch/Resources/Version.h" + using namespace v8; static const int kContextEmbedderDataIndex = 0; @@ -1947,8 +1948,11 @@ class FJavascriptContextImplementation : public FJavascriptContext auto Function = *FuncIt; // Parse all function parameters. - uint8* Parms = (uint8*)FMemory_Alloca(Function->ParmsSize); - FMemory::Memzero(Parms, Function->ParmsSize); + TArray Parms = TArray();// = (uint8*)FMemory_Alloca(Function->ParmsSize); + //FMemory::Memzero(Parms, Function->ParmsSize); + Parms.SetNumUninitialized(Function->ParmsSize); + FMemory::Memzero(Parms.GetData(), Parms.Num()); + bool bHasDefault = false; TArray Parameters, ParametersWithDefaults; @@ -1963,7 +1967,7 @@ class FJavascriptContextImplementation : public FJavascriptContext if (!MetadataCppDefaultValue.IsEmpty()) { const uint32 ExportFlags = PPF_None; - auto Buffer = It->ContainerPtrToValuePtr(Parms); + auto Buffer = It->ContainerPtrToValuePtr(Parms.GetData()); #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1 const TCHAR* Result = It->ImportText_Direct(*MetadataCppDefaultValue, Buffer, nullptr, ExportFlags); @@ -1974,7 +1978,7 @@ class FJavascriptContextImplementation : public FJavascriptContext if (Result) { bHasDefault = true; - auto DefaultValue = Environment->ReadProperty(isolate(), Property, Parms, FNoPropertyOwner()); + auto DefaultValue = Environment->ReadProperty(isolate(), Property, Parms.GetData(), FNoPropertyOwner()); { auto ctx = context(); Context::Scope context_scope(ctx); @@ -1989,7 +1993,7 @@ class FJavascriptContextImplementation : public FJavascriptContext } } - It->DestroyValue_InContainer(Parms); + //It->DestroyValue_InContainer(Parms); } } Parameters.Add(Parameter); diff --git a/Source/V8/V8.Build.cs b/Source/V8/V8.Build.cs index d7396264..abe53bbd 100644 --- a/Source/V8/V8.Build.cs +++ b/Source/V8/V8.Build.cs @@ -83,10 +83,10 @@ private void HackWebSocketIncludeDir(String WebsocketPath, ReadOnlyTargetRules T bHasZlib = true; } - else if (Target.Platform == UnrealTargetPlatform.Linux) - { - PlatformSubdir = Path.Combine(PlatformSubdir, Target.Architecture); - } + // else if (Target.Platform == UnrealTargetPlatform.Linux) + // { + // PlatformSubdir = Path.Combine(PlatformSubdir, Target.Architecture); + // } PrivateDependencyModuleNames.Add("libWebSockets"); From 0ebd61229130e0b53e1267eff98a8f49e05af51b Mon Sep 17 00:00:00 2001 From: Pratik Chavan Date: Mon, 26 Jun 2023 19:25:57 +0530 Subject: [PATCH 2/5] fixed crash with ndisplay launch? --- Source/V8/Private/JavascriptIsolate_Private.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/V8/Private/JavascriptIsolate_Private.cpp b/Source/V8/Private/JavascriptIsolate_Private.cpp index 42b6a626..4f5b0354 100644 --- a/Source/V8/Private/JavascriptIsolate_Private.cpp +++ b/Source/V8/Private/JavascriptIsolate_Private.cpp @@ -378,7 +378,13 @@ class FJavascriptIsolateImplementation : public FJavascriptIsolate params.array_buffer_allocator = &AllocatorInstance; // Bind this instance to newly created V8 isolate - RegisterSelf(Isolate::New(params)); + // Bind this instance to newly created V8 isolate + Isolate* iso = nullptr; + iso = Isolate::New(params); + if (iso) + { + RegisterSelf(iso); + } GenerateBlueprintFunctionLibraryMapping(); From 4f8b4fae5d751dcd94ba67e36522a80d68dff4b4 Mon Sep 17 00:00:00 2001 From: Pratik Chavan Date: Mon, 26 Jun 2023 19:31:22 +0530 Subject: [PATCH 3/5] Revert "fixed crash with ndisplay launch?" This reverts commit 0ebd61229130e0b53e1267eff98a8f49e05af51b. --- Source/V8/Private/JavascriptIsolate_Private.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Source/V8/Private/JavascriptIsolate_Private.cpp b/Source/V8/Private/JavascriptIsolate_Private.cpp index 4f5b0354..42b6a626 100644 --- a/Source/V8/Private/JavascriptIsolate_Private.cpp +++ b/Source/V8/Private/JavascriptIsolate_Private.cpp @@ -378,13 +378,7 @@ class FJavascriptIsolateImplementation : public FJavascriptIsolate params.array_buffer_allocator = &AllocatorInstance; // Bind this instance to newly created V8 isolate - // Bind this instance to newly created V8 isolate - Isolate* iso = nullptr; - iso = Isolate::New(params); - if (iso) - { - RegisterSelf(iso); - } + RegisterSelf(Isolate::New(params)); GenerateBlueprintFunctionLibraryMapping(); From 6c52d4a3adcc20098812f8bc57d47adc7252aca0 Mon Sep 17 00:00:00 2001 From: Pratik Chavan Date: Mon, 26 Jun 2023 19:32:16 +0530 Subject: [PATCH 4/5] ndisplay crash fixed --- UnrealJS.uplugin | 1 - 1 file changed, 1 deletion(-) diff --git a/UnrealJS.uplugin b/UnrealJS.uplugin index eff3a885..01ae0d9b 100644 --- a/UnrealJS.uplugin +++ b/UnrealJS.uplugin @@ -4,7 +4,6 @@ "Version": 2, "VersionName": "0.6.4", "FriendlyVersion": "0.6.4", - "EngineVersion": "5.1.0", "Description": "Javascript powered UnrealEngine", "Category": "Programming", "CreatedBy": "NCSOFT Corporation", From 8c95251dea67032e72c49ea5d4c85f7a76febbfa Mon Sep 17 00:00:00 2001 From: Pelle Johnsen Date: Tue, 12 Sep 2023 08:24:14 +0200 Subject: [PATCH 5/5] feat: Fixes for 5.3 --- Source/JavascriptEditor/JavascriptEditorViewport.cpp | 2 +- Source/JavascriptEditor/JavascriptUICommands.cpp | 2 +- Source/JavascriptHttp/JavascriptHttpRequest.h | 2 +- Source/JavascriptUMG/JavascriptGameViewport.cpp | 2 +- Source/JavascriptUMG/JavascriptWindow.cpp | 2 +- Source/V8/Private/JavascriptIsolate_Private.cpp | 2 +- Source/V8/Private/JavascriptLibrary.cpp | 2 +- Source/V8/Private/Translator.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/JavascriptEditor/JavascriptEditorViewport.cpp b/Source/JavascriptEditor/JavascriptEditorViewport.cpp index c501ec7c..9cebe1fa 100644 --- a/Source/JavascriptEditor/JavascriptEditorViewport.cpp +++ b/Source/JavascriptEditor/JavascriptEditorViewport.cpp @@ -6,7 +6,7 @@ #include "Engine/Canvas.h" #include "Components/OverlaySlot.h" #include "AssetViewerSettings.h" -#include "Launch/Resources/Version.h" +#include "Runtime/Launch/Resources/Version.h" #include "Components/DirectionalLightComponent.h" #if ENGINE_MAJOR_VERSION > 4 #include "UnrealWidget.h" diff --git a/Source/JavascriptEditor/JavascriptUICommands.cpp b/Source/JavascriptEditor/JavascriptUICommands.cpp index aa89380d..bfa4d219 100644 --- a/Source/JavascriptEditor/JavascriptUICommands.cpp +++ b/Source/JavascriptEditor/JavascriptUICommands.cpp @@ -1,7 +1,7 @@ #include "JavascriptUICommands.h" #include "JavascriptMenuLibrary.h" #include "Framework/Commands/Commands.h" -#include "Launch/Resources/Version.h" +#include "Runtime/Launch/Resources/Version.h" //PRAGMA_DISABLE_OPTIMIZATION diff --git a/Source/JavascriptHttp/JavascriptHttpRequest.h b/Source/JavascriptHttp/JavascriptHttpRequest.h index e8182cc7..5dda2f96 100644 --- a/Source/JavascriptHttp/JavascriptHttpRequest.h +++ b/Source/JavascriptHttp/JavascriptHttpRequest.h @@ -7,7 +7,7 @@ #include "Interfaces/IHttpRequest.h" #include "Interfaces/IHttpResponse.h" #include "HttpModule.h" -#include "Launch/Resources/Version.h" +#include "Runtime/Launch/Resources/Version.h" #include "JavascriptHttpRequest.generated.h" diff --git a/Source/JavascriptUMG/JavascriptGameViewport.cpp b/Source/JavascriptUMG/JavascriptGameViewport.cpp index 08f80164..3e5f4e6b 100644 --- a/Source/JavascriptUMG/JavascriptGameViewport.cpp +++ b/Source/JavascriptUMG/JavascriptGameViewport.cpp @@ -8,7 +8,7 @@ #include "SceneView.h" #include "CanvasTypes.h" #include "Widgets/SViewport.h" -#include "Launch/Resources/Version.h" +#include "Runtime/Launch/Resources/Version.h" #define LOCTEXT_NAMESPACE "UMG" diff --git a/Source/JavascriptUMG/JavascriptWindow.cpp b/Source/JavascriptUMG/JavascriptWindow.cpp index 170f7511..8e704f90 100644 --- a/Source/JavascriptUMG/JavascriptWindow.cpp +++ b/Source/JavascriptUMG/JavascriptWindow.cpp @@ -1,6 +1,6 @@ #include "JavascriptWindow.h" #include "Widgets/SWindow.h" -#include "Launch/Resources/Version.h" +#include "Runtime/Launch/Resources/Version.h" UJavascriptWindow::UJavascriptWindow(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) diff --git a/Source/V8/Private/JavascriptIsolate_Private.cpp b/Source/V8/Private/JavascriptIsolate_Private.cpp index 42b6a626..f577d28a 100644 --- a/Source/V8/Private/JavascriptIsolate_Private.cpp +++ b/Source/V8/Private/JavascriptIsolate_Private.cpp @@ -1788,7 +1788,7 @@ class FJavascriptIsolateImplementation : public FJavascriptIsolate auto Function = reinterpret_cast((Local::Cast(info.Data()))->Value()); // Determine 'this' - auto Object = (Function->FunctionFlags & FUNC_Static) ? Function->GetOwnerClass()->ClassDefaultObject : UObjectFromV8(isolate->GetCurrentContext(), self); + auto Object = (Function->FunctionFlags & FUNC_Static) ? Function->GetOwnerClass()->ClassDefaultObject.Get() : UObjectFromV8(isolate->GetCurrentContext(), self); // Check 'this' is valid if (!IsValid(Object)) diff --git a/Source/V8/Private/JavascriptLibrary.cpp b/Source/V8/Private/JavascriptLibrary.cpp index d9813155..91677be3 100644 --- a/Source/V8/Private/JavascriptLibrary.cpp +++ b/Source/V8/Private/JavascriptLibrary.cpp @@ -6,7 +6,7 @@ #include "Sockets.h" #include "NavigationSystem.h" #include "HAL/PlatformApplicationMisc.h" -#include "Launch/Resources/Version.h" +#include "Runtime/Launch/Resources/Version.h" #include "Misc/FileHelper.h" #include "Misc/Paths.h" #include "UObject/MetaData.h" diff --git a/Source/V8/Private/Translator.cpp b/Source/V8/Private/Translator.cpp index 704e31ee..c701d649 100644 --- a/Source/V8/Private/Translator.cpp +++ b/Source/V8/Private/Translator.cpp @@ -1,6 +1,6 @@ #include "Translator.h" #include "Engine/UserDefinedStruct.h" -#include "Launch/Resources/Version.h" +#include "Runtime/Launch/Resources/Version.h" namespace v8 {