No callstack provided because I was able to repro this in vanilla Lyra 5.7 and I attached the crash artifacts. I can also repro this in 5.4 in our studio project, for what it’s worth.
Error:
Fatal error: [File D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\EditorServer.cpp] [Line: 2524]
World Memory Leaks: 2 leaks objects and packages. See The output above.
It seems that python script references are somehow causing this error to be thrown. I’ve seen other crashes in this way through different repros that I have not been able to replicate.
Steps to Reproduce
- Create a new Lyra Starter Game Project using UE 5.7
- Switch the console type to python
- Enter the following python command:
asset_registry = unreal.AssetRegistryHelpers.get_asset_registry();asset_data = asset_registry.get_assets_by_package_name('/Game/System/TransitionMap')[0]; level = asset_data.get_asset(); unreal.get_editor_subsystem(unreal.AssetEditorSubsystem).open_editor_for_assets([level])
4. Crash
Hi Grant,
I did some investigation into this. It seems this is an unfortunate interaction between Python and the Editor’s level loading process requirements. It is related (even if not exactly the same) to this known situation here: UE-177376 (note that it was marked as a non-issue, see explanation below).
When the Editor opens a Level, it must do so from disk, and never from memory, because that is currently the only way that ensures its world will be initialized correctly. Moreover, the level being opened cannot already be in memory when the process begins. The Editor tries to make sure of that by destroying the current world, unloading any loaded world packages, and letting the GC clean everything up.
Now, while the reference returned by “asset_data.get_asset()” is held by the python script, the GC is not allowed to clean it up. When the Editor attempts to open that level, it detects that it is still in memory when it shouldn’t, so it just logs a fatal message and crashes. Unfortunately, this makes it impossible to use “unreal.AssetEditorSubsystem.open_editor_for_assets([LevelObject])” to open a level, since that function must receive a live reference to the desired asset. Instead, when working with level assets, you must release any Python references to any level, then use “unreal.LevelEditorSubsystem.load_level(”/Path/To/Level"). In your case, simply replace all of the code you provided with this:
unreal.get_editor_subsystem(unreal.LevelEditorSubsystem).load_level("/Game/System/TransitionMap")Please let me know if this solution works for you!
Best regards,
Vitor
Thank you for the detailed explanation and pointing me to the load_level command! My local tests work - this will indeed fix a crash we were experiencing.
However, we have some other harder to repro crashes we experience that also show python references causing a crash on level load. Due to the extensive nature of our python scripting, it might take some time to pin down what is holding on to that reference. But now that we know the problem, I think we’ll be able to track down the offending logic eventually.