Creating PCG Assets from Level(s) causes Unreal Editor to crash

Reproduction steps:

  1. Create a new empty level (Level_A)
  2. Create a new empty level (Level_B)
  3. Open Level_A
  4. Open “Levels” window (Window -> Levels)
  5. Add Level_B into Level_A (Levels drop down -> Add Existing -> Level_B)
  6. Reopen Level_A to make sure changes are saved
  7. Run the “Create PCG Assets from Level(s)” command on Level_B (right click on Level_B in the content browser -> Asset Actions -> Create PCG Assets from Level(s))

If you are missing the command in Asset Actions, make sure you have Procedural Content Generation Framework (PCG) plugin enabled.

[Image Removed]

After looking deeper into this problem, the editor crashes on this subsystem check inside

Engine\Plugins\PCG\Source\PCGEditor\Private\PCGLevelToAsset.cpp:

ULevelInstanceSubsystem* LevelInstanceSubsystem = UWorld::GetSubsystem<ULevelInstanceSubsystem>(World);
check(LevelInstanceSubsystem);

The World is not initialized at this point so the GetSubsystem returns nullptr.

Steps to Reproduce
I’ve encountered an editor crash when using the “Asset Actions -> Create PCG Assets from Level(s)” command. When this command is used on a level that exists as a sublevel of another loaded level the editor always crashes. This can be easily reproduced in an empty project (see reproduction steps below).

[Image Removed]

Hi Lukas, can you confirm that this does not crash if the sub level you are trying to create the PCG Asset from isn’t loaded?

I think I understand the issue, the issue is that sub-levels do not have subsystems, only the main level (world) has them. When exporting expect the world being passed to be a main world, this is not possible if the world being passed is actually a sub-world (sub-level).

We will make sure it doesn’t crash but the fix is probably to notify the user to close the level before exporting.

Here is the public link to the issue: Unreal Engine Issues and Bug Tracker (UE\-314870)

(give it time before it actually links to something useful)

Cheers,

Patrick

Hi Patrick, thanks for you answer.

If I don’t add the existing level (Level_B) into the other level (Level_A) as sublevel, then creating the PCG Asset works fine. No matter if I have the level opened or not.

Yes that is expected, what I wanted you to test is adding keeping it as a sub-level of A but unloading level A so that level B is no longer loaded as a sub-level, then trying to export and it should work.