Tencent / UnLua

A feature-rich, easy-learning and highly optimized Lua scripting plugin for UE.
Other
2.28k stars 619 forks source link

引擎版本4.27.2,编译(生成)项目有两个必现崩溃操作 #492

Open LeeCarry opened 2 years ago

LeeCarry commented 2 years ago

1. 复现步骤:先点击Play运行游戏,再Stop停止游戏,修改Plugins内的一处代码,再点击Play,就会崩溃。 UE Editor崩溃堆栈:

UE4Editor_UnLua_0004!UnLua::FLuaEnv::FindEnvChecked() [F:\X\external\UnLua\Plugins\UnLua\Source\UnLua\Private\LuaEnv.cpp:167]
UE4Editor_UnLua_0004!FFunctionDesc::CallLuaInternal() [F:\X\external\UnLua\Plugins\UnLua\Source\UnLua\Private\ReflectionUtils\FunctionDesc.cpp:622]
UE4Editor_UnLua_0004!FFunctionDesc::CallLua() [F:\X\external\UnLua\Plugins\UnLua\Source\UnLua\Private\ReflectionUtils\FunctionDesc.cpp:248]
UE4Editor_UnLua_0004!UnLua::FFunctionRegistry::Invoke() [F:\X\external\UnLua\Plugins\UnLua\Source\UnLua\Private\Registries\FunctionRegistry.cpp:85]
UE4Editor_UnLua_0004!ULuaFunction::execCallLua() [F:\X\external\UnLua\Plugins\UnLua\Source\UnLua\Private\LuaFunction.cpp:47]
UE4Editor_CoreUObject!UFunction::Invoke() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5679]
UE4Editor_CoreUObject!UObject::ProcessEvent() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2018]
UE4Editor_Engine!UGameInstance::Init() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\GameInstance.cpp:77]
UE4Editor_Engine!UGameInstance::InitializeForPlayInEditor() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\GameInstance.cpp:320]
UE4Editor_UnrealEd!UEditorEngine::CreateInnerProcessPIEGameInstance() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:2785]
UE4Editor_UnrealEd!UEditorEngine::OnLoginPIEComplete_Deferred() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:1503]
UE4Editor_UnrealEd!UEditorEngine::CreateNewPlayInEditorInstance() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:1750]
UE4Editor_UnrealEd!UEditorEngine::StartPlayInEditorSession() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:2713]
UE4Editor_UnrealEd!UEditorEngine::StartQueuedPlaySessionRequestImpl() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:1116]
UE4Editor_UnrealEd!UEditorEngine::StartQueuedPlaySessionRequest() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp:1019]
UE4Editor_UnrealEd!UEditorEngine::Tick() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1629]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:426]
UE4Editor!FEngineLoop::Tick() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4921]
UE4Editor!GuardedMain() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:178]
UE4Editor!GuardedMainWrapper() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:137]
UE4Editor!LaunchWindowsStartup() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:273]
UE4Editor!WinMain() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:320]
UE4Editor!__scrt_common_main_seh() [d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

尝试过断点跟了一下,在UnluaModule::NotifyUObjectCreated里的const auto Env = EnvLocator->Locate(Object);这条语句是进不去的,导致LuaEnv没有初始化,但是这里的EnvLocator是被初始化过的,推测可能是因为编译生成后的HotReload有一些数据没完全更新到,EnvLocator实例已经错了。

2. 复现步骤:打开unlua示例项目,修改Plugins里的一处代码(随便加个空格即可),编译项目生成DLL,再修改Plugins里的一处代码,再编译,编译完成后就会崩溃。 UE Editor崩溃堆栈:

Assertion failed: !TickableObjects.Contains(TickableObject) [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/Engine/Private/Tickable.cpp] [Line: 40]

UE4Editor_Core!AssertFailedImplV() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:104]
UE4Editor_Core!FDebug::CheckVerifyFailedImpl() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:461]
UE4Editor_Engine!FTickableObjectBase::AddTickableObject() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\Tickable.cpp:40]
UE4Editor_Engine!FTickableGameObject::TickObjects() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\Tickable.cpp:119]
UE4Editor_Engine!UWorld::Tick() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1563]
UE4Editor_UnrealEd!UEditorEngine::Tick() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1534]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:426]
UE4Editor!FEngineLoop::Tick() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4921]
UE4Editor!GuardedMain() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:178]
UE4Editor!GuardedMainWrapper() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:137]
UE4Editor!LaunchWindowsStartup() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:273]
UE4Editor!WinMain() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:320]
UE4Editor!__scrt_common_main_seh() [d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

PS: 其实倒也不是对Plugin修改的频繁,只是用UE427时触发了另一个BUG,如果Plugin的Binaries第一次就是用VS生成出来的,那就会每次(哪怕只改项目代码)也会触发Plugin重编,如果第一次就是使用UE自带的编译出来的则没事,所以在频繁触发Plugin重编的情况下发现了上面两个问题,在别人那也能重现。

xuyanghuang-tencent commented 2 years ago

这个目前没有什么很好的办法来处理,UE4的HotReload局限性比较大,或者可以试试live coding,UE5下已经是正式功能了。