Blueprints loading and compilation order

Calling for engine adepts. :head_shaking_vertically:

I’m making a plugin that creates K2Node based on other blueprints.
It doesn’t always work stably… But usually this doesn’t cause serious problems.

But recently I found a 100% way to break it (unfortunately :grin:)

Apparently the dependency tracking and loading object (blueprint compilation?) system doesn’t always work as I need it to.

If I open the persistence level immediately after loading the editor, I get this crash:

Assertion failed: !InClass || (InClass->ClassWithin && InClass->ClassConstructor) [File:D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 3106]

Here are the dependencies:

If after loading the editor I immediately open the sublevel, or if before opening the Persistence level I open (load) the blueprint in which my node is located, then the problem disappears.

The crash only happens in the editor. In the build, everything works as it should.

The node stores a TSoftObjectPtr< UBlueprint >, and calls LoadSynchronous() when required.

I guess I need to somehow force the engine to load all blueprints that contain my nodes from the beginning, so that they don’t get compiled while other objects are loading.

I tried (probably incorrectly) to use Primary Assets - but the manager doesn’t exist yet at the loading stage of my plugin. :roll_eyes:

I would like to know how to do it correctly. Or maybe you have other versions of the origin/solution of the problem. I will be glad to hear them.

UPD2

CallStack.txt (13.9 KB)
MyFile.txt (369 Bytes)

Stop point:

Last stop point before crash:

Thanks in advance.

UPD
Also after loading some projects where my plugin is used, an error appears:

LogOutputDevice: Error: Ensure condition failed: QueuedRequests.Num() == 0  [File:D:\build\++UE5\Sync\Engine\Source\Editor\Kismet\Private\BlueprintCompilationManager.cpp] [Line: 1715] 

But they are successfully built and work. :melting_face:

I was right (I think).

I’m still not sure I used it as it was originally intended, but now it does what I need it to. :sweat_smile:

In the end, I created two blueprints that contain list (autofilled every time the engine is loaded) of hard references for assets that need to be loaded before the rest. Some of them should be loaded before the others, so there are two lists.

Then they had to be added as primary assets, being sure to follow the order in which they were placed in the array where the primary assets were specified.

Now my log is clean and I haven’t gotten any weird crashes like before.