Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UE] Bug: v8::Isolate::New crashes Unreal Editor the second time I run the Editor #1856

Open
3 tasks done
cf opened this issue Oct 8, 2024 · 1 comment
Open
3 tasks done
Assignees
Labels
bug Something isn't working Unreal

Comments

@cf
Copy link

cf commented Oct 8, 2024

前置阅读 | Pre-reading

Puer的版本 | Puer Version

1.0.5

UE的版本 | UE Version

5.4.4

发生在哪个平台 | Platform

Editor(mac)

错误信息 | Error Message


Caught signal

v8::internal::GetPlatformPageAllocator() Address = 0x4ddc7c5b8 (filename not found) [in UnrealEditor-JsEnv-0052.dylib]
v8::internal::IsolateAllocator::IsolateAllocator() Address = 0x4dd95e7a4 (filename not found) [in UnrealEditor-JsEnv-0052.dylib]
v8::internal::Isolate::New() Address = 0x4dd81cad4 (filename not found) [in UnrealEditor-JsEnv-0052.dylib]
v8::Isolate::New(v8::Isolate::CreateParams const&) Address = 0x4dd6c84e4 (filename not found) [in UnrealEditor-JsEnv-0052.dylib]
puerts::FJsEnvImpl::FJsEnvImpl(std::__1::shared_ptr<puerts::IJSModuleLoader>, std::__1::shared_ptr<puerts::ILogger>, int, std::__1::function<void (FString const&)>, FString, void*, void*) Address = 0x4de25a2a0 (filename not found) [in UnrealEditor-JsEnv-0052.dylib]
std::__1::__unique_if<puerts::FJsEnvImpl>::__unique_single std::__1::make_unique[abi:ne180100]<puerts::FJsEnvImpl, std::__1::shared_ptr<puerts::IJSModuleLoader>, std::__1::shared_ptr<puerts::ILogger>&, int&, std::__1::function<void (FString const&)>&, FString const&, void*&, void*&>(std::__1::shared_ptr<puerts::IJSModuleLoader>&&, std::__1::shared_ptr<puerts::ILogger>&, int&, std::__1::function<void (FString const&)>&, FString const&, void*&, void*&) Address = 0x4de1d5c08 [/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h, line 597] [in UnrealEditor-JsEnv-0052.dylib]
puerts::FJsEnv::FJsEnv(std::__1::shared_ptr<puerts::IJSModuleLoader>, std::__1::shared_ptr<puerts::ILogger>, int, std::__1::function<void (FString const&)>, FString, void*, void*) Address = 0x4de1d5dc8 [/Users/carter/Documents/Unreal Projects/LyraStarterGame3/Plugins/Puerts/Source/JsEnv/Private/JsEnv.cpp, line 22] [in UnrealEditor-JsEnv-0052.dylib]
SharedPointerInternals::TIntrusiveReferenceController<puerts::FJsEnv, (ESPMode)1>::TIntrusiveReferenceController<std::__1::unique_ptr<puerts::DefaultJSModuleLoader, std::__1::default_delete<puerts::DefaultJSModuleLoader>>, std::__1::shared_ptr<puerts::FDefaultLogger>, int>(std::__1::unique_ptr<puerts::DefaultJSModuleLoader, std::__1::default_delete<puerts::DefaultJSModuleLoader>>&&, std::__1::shared_ptr<puerts::FDefaultLogger>&&, int&&) Address = 0x4a9299e2c [/Users/Shared/Epic Games/UE_5.4/Engine/Source/Runtime/Core/Public/Templates/SharedPointerInternals.h, line 414] [in UnrealEditor-LyraGame-4663.dylib]
UMSCLevelCore::InitJS() Address = 0x4a9296cc4 [/Users/carter/Documents/Unreal Projects/LyraStarterGame3/Source/LyraGame/MSC/MSCLevelCore.cpp, line 91] [in UnrealEditor-LyraGame-4663.dylib]
UMSCLevelCore::ServerSetupMSCScript_Implementation() Address = 0x4a9298620 [/Users/carter/Documents/Unreal Projects/LyraStarterGame3/Source/LyraGame/MSC/MSCLevelCore.cpp, line 284] [in UnrealEditor-LyraGame-4663.dylib]
UFunction::Invoke(UObject*, FFrame&, void*) Address = 0x106ff241c (filename not found) [in UnrealEditor-CoreUObject.dylib]
UObject::ProcessEvent(UFunction*, void*) Address = 0x10739e5fc (filename not found) [in UnrealEditor-CoreUObject.dylib]
TBaseUObjectMethodDelegateInstance<false, UMSCLevelCore, void (ULyraExperienceDefinition const*), FDefaultDelegateUserPolicy>::ExecuteIfSafe(ULyraExperienceDefinition const*) const Address = 0x4a929c394 [/Users/Shared/Epic Games/UE_5.4/Engine/Source/Runtime/Core/Public/Delegates/DelegateInstancesImpl.h, line 654] [in UnrealEditor-LyraGame-4663.dylib]
void TMulticastDelegateBase<FDefaultDelegateUserPolicy>::Broadcast<IBaseDelegateInstance<void (ULyraExperienceDefinition const*), FDefaultDelegateUserPolicy>, ULyraExperienceDefinition const*>(ULyraExperienceDefinition const*) const Address = 0x4a920e250 [/Users/Shared/Epic Games/UE_5.4/Engine/Source/Runtime/Core/Public/Delegates/MulticastDelegateBase.h, line 254] [in UnrealEditor-LyraGame-4663.dylib]
ULyraExperienceManagerComponent::OnExperienceFullLoadCompleted() Address = 0x4a920ada8 [/Users/carter/Documents/Unreal Projects/LyraStarterGame3/Source/LyraGame/GameModes/LyraExperienceManagerComponent.cpp, line 348] [in UnrealEditor-LyraGame-4663.dylib]
TBaseUObjectMethodDelegateInstance<false, ULyraExperienceManagerComponent, void (UE::GameFeatures::FResult const&), FDefaultDelegateUserPolicy>::ExecuteIfSafe(UE::GameFeatures::FResult const&) const Address = 0x4a920dc98 [/Users/Shared/Epic Games/UE_5.4/Engine/Source/Runtime/Core/Public/Delegates/DelegateInstancesImpl.h, line 654] [in UnrealEditor-LyraGame-4663.dylib]
UGameFeaturesSubsystem::ChangeGameFeatureTargetStateComplete(UGameFeaturePluginStateMachine*, UE::GameFeatures::FResult const&, TDelegate<void (UE::GameFeatures::FResult const&), FDefaultDelegateUserPolicy>) Address = 0x3ff6503cc (filename not found) [in UnrealEditor-GameFeatures.dylib]
TBaseUObjectMethodDelegateInstance<false, UGameFeaturesSubsystem, void (UGameFeaturePluginStateMachine*, UE::GameFeatures::FResult const&), FDefaultDelegateUserPolicy, TDelegate<void (UE::GameFeatures::FResult const&), FDefaultDelegateUserPolicy>>::ExecuteIfSafe(UGameFeaturePluginStateMachine*, UE::GameFeatures::FResult const&) const Address = 0x3ff6b5a2c (filename not found) [in UnrealEditor-GameFeatures.dylib]
void TMulticastDelegateBase<FDefaultDelegateUserPolicy>::Broadcast<IBaseDelegateInstance<void (UGameFeaturePluginStateMachine*, UE::GameFeatures::FResult const&), FDefaultDelegateUserPolicy>, UGameFeaturePluginStateMachine*, UE::GameFeatures::FResult const&>(UGameFeaturePluginStateMachine*, UE::GameFeatures::FResult const&) const Address = 0x3ff667b80 (filename not found) [in UnrealEditor-GameFeatures.dylib]
UGameFeaturePluginStateMachine::UpdateStateMachine()::$_51::operator()(UE::GameFeatures::FResult const&, unsigned char, unsigned char) const Address = 0x3ff63a860 (filename not found) [in UnrealEditor-GameFeatures.dylib]
UGameFeaturePluginStateMachine::UpdateStateMachine() Address = 0x3ff638ca4 (filename not found) [in UnrealEditor-GameFeatures.dylib]
UGameFeaturePluginStateMachine::SetDestination(FGameFeaturePluginStateRange, TDelegate<void (UGameFeaturePluginStateMachine*, UE::GameFeatures::FResult const&), FDefaultDelegateUserPolicy>, FDelegateHandle*) Address = 0x3ff639988 (filename not found) [in UnrealEditor-GameFeatures.dylib]
UGameFeaturesSubsystem::ChangeGameFeatureDestination(UGameFeaturePluginStateMachine*, FGameFeatureProtocolOptions const&, FGameFeaturePluginStateRange const&, TDelegate<void (UE::GameFeatures::FResult const&), FDefaultDelegateUserPolicy>) Address = 0x3ff6480cc (filename not found) [in UnrealEditor-GameFeatures.dylib]
UGameFeaturesSubsystem::ChangeGameFeatureTargetState(FString const&, FGameFeatureProtocolOptions const&, EGameFeatureTargetState, TDelegate<void (UE::GameFeatures::FResult const&), FDefaultDelegateUserPolicy> const&) Address = 0x3ff6493bc (filename not found) [in UnrealEditor-GameFeatures.dylib]
UGameFeaturesSubsystem::LoadAndActivateGameFeaturePlugin(FString const&, TDelegate<void (UE::GameFeatures::FResult const&), FDefaultDelegateUserPolicy> const&) Address = 0x3ff63f768 (filename not found) [in UnrealEditor-GameFeatures.dylib]
ULyraExperienceManagerComponent::OnExperienceLoadComplete() Address = 0x4a920a584 [/Users/carter/Documents/Unreal Projects/LyraStarterGame3/Source/LyraGame/GameModes/LyraExperienceManagerComponent.cpp, line 269] [in UnrealEditor-LyraGame-4663.dylib]
TBaseUObjectMethodDelegateInstance<false, ULyraExperienceManagerComponent, void (), FDefaultDelegateUserPolicy>::ExecuteIfSafe() const Address = 0x4a920d3a0 [/Users/Shared/Epic Games/UE_5.4/Engine/Source/Runtime/Core/Public/Delegates/DelegateInstancesImpl.h, line 654] [in UnrealEditor-LyraGame-4663.dylib]
FStreamableDelegateDelayHelper::Tick(float) Address = 0x11c8d73e8 (filename not found) [in UnrealEditor-Engine.dylib]
FTickableGameObject::TickObjects(UWorld*, int, bool, float) Address = 0x11ca10738 (filename not found) [in UnrealEditor-Engine.dylib]
UEditorEngine::Tick(float, bool) Address = 0x1149cfbe4 (filename not found) [in UnrealEditor-UnrealEd.dylib]
UUnrealEdEngine::Tick(float, bool) Address = 0x115800f60 (filename not found) [in UnrealEditor-UnrealEd.dylib]
ULyraEditorEngine::Tick(float, bool) Address = 0x3867abd50 (filename not found) [in UnrealEditor-LyraEditor-5465.dylib]
FEngineLoop::Tick() Address = 0x104b8636c (filename not found) [in UnrealEditor]
GuardedMain(char16_t const*) Address = 0x104b933c4 (filename not found) [in UnrealEditor]
-[UEAppDelegate runGameThread:] Address = 0x104bad364 (filename not found) [in UnrealEditor]
-[FCocoaGameThread main] Address = 0x108c009c4 (filename not found) [in UnrealEditor-Core.dylib]
Unknown() Address = 0x1932c9f80 (filename not found) [in Foundation]
Unknown() Address = 0x1920bef94 (filename not found) [in libsystem_pthread.dylib]
Unknown() Address = 0x1920b9d34 (filename not found) [in libsystem_pthread.dylib]

问题重现 | Bug reproduce

问题好奇怪,我第一次按start在编辑器没有问题,但如果我stop,HotReload/Compile,下次启动JsEnv就抱着个错误。

Startup Code:

void UMSCLevelCore::InitJS()
{
	if (isScriptLoaded)
	{
		UE_LOG(LogLyraExperience, Log, TEXT("Script already loaded"));
		return;
	}
	isScriptLoaded = true;
	UE_LOG(LogLyraExperience, Log, TEXT("Loading Script..."));

	// JsEnv = MakeShared<puerts::FJsEnv>(TEXT("JavaScript"));
	JsEnv = MakeShared<puerts::FJsEnv>(std::make_unique<puerts::DefaultJSModuleLoader>(TEXT("JavaScript")), std::make_shared<puerts::FDefaultLogger>(), 8089);

	TArray<TPair<FString, UObject *>> Arguments;
	Arguments.Add(TPair<FString, UObject *>(TEXT("LevelCore"), this));
	JsEnv->Start("QuickStart", Arguments);
	isRunning = true;
}

TearDown Code:

void UMSCLevelCore::MSCTearDown()
{
	UE_LOG(LogLyraExperience, Log, TEXT("UMSCLevelCore::MSCTearDown"));
	if (isRunning)
	{
		isRunning = false;
		UE_LOG(LogLyraExperience, Log, TEXT("UMSCLevelCore::MSCTearDown real"));
		UGameplayMessageSubsystem &MessageSubsystem = UGameplayMessageSubsystem::Get(this);

		for (FGameplayMessageListenerHandle &Handle : ListenerHandles)
		{
			MessageSubsystem.UnregisterListener(Handle);
		}
		ListenerHandles.Empty();

		// GameMode->OnGameModePlayerInitialized.Remove(&ThisClass::OnPlayerConnected);
		FGameModeEvents::GameModeLogoutEvent.RemoveAll(this);

		if (isScriptLoaded)
		{
			JsEnv.Reset();
			isScriptLoaded = false;
		}
	}
}
void UMSCLevelCore::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
	Super::EndPlay(EndPlayReason);
	UE_LOG(LogLyraExperience, Log, TEXT("EndPlay"));

	// isRunning

	MSCTearDown();
}
@cf cf added bug Something isn't working Unreal labels Oct 8, 2024
@chexiongsheng
Copy link
Collaborator

v8用了静态变量。应该是ue的c++ HotReload没有把静态变量的状态也迁移过去导致的。
puerts是通过反射去修改bCanHotReload变量禁用HotReload:https://github.com/Tencent/puerts/blob/master/unreal/Puerts/Source/JsEnv/JsEnv.Build.cs#L97
这之前ue各版本都工作的好好的,可能是5.4.4失效了,你可以看看ubt代码,看看要怎么修改。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Unreal
Projects
None yet
Development

No branches or pull requests

2 participants