UE 5.2 crashes often when compiling blueprints.

SOLUTION:
Do not reference self if your event might run after actor is destroyed, especially if you’re spawning a duplicate actor, it creates a dependency that breaks the engine.


I’m using UE 5.2, have been for a while on the same project, and suddenly last night it started freezing about 80 - 90% of the time I compile a blueprint.

It is not a crash with a crash screen, the engine stops responding, hogs a bunch of ram, and freezes indefinitely.

The times when compiling works, it works instantly as my code isn’t that heavy.
When End task through the task manager and restart the engine, it may compile fine or may freeze again, requiring a different restart.

Does anyone have any idea why this is happening?

Screenshots of the crash:
image

After a restart

image
Compiles just fine and runs instantly.

Update:
No progress, crash still occurs,
updates:

  1. Deleted Build, Intermediate, and saved folders.

  2. Migrated asset to a blank project.

  3. Removed all constructions scripts except for the one in an unrelated BP.
    image

  4. Added asset to blank level.

  5. Checked reference for circular dependencies:

  6. Project packaging and running works fine.

  7. Created a child blueprint class of the affected blueprints, also freezes the editor on compile.

  8. Tested on a different machine.

  9. Made a new Blueprint with the same functionality.

  10. Removed implemented interfaces and their corresponding functionality.

Still have not found a solution, the crashes continue.

Device
Processor Intel(R) Core™ i7-10700K CPU @ 3.80GHz 3.79 GHz
Installed RAM 32.0 GB (31.9 GB usable)
Device ID 7F3B23EF-C33C-45D9-9949-B41FE0520240
Product ID 00330-80000-00000-AA762
System type 64-bit operating system, x64-based processor
Pen and touch Pen support

Nvidia 2080 super.

My system btw, if that’s relevant

Update, It seems to crash when compiling specific blueprints, but I don’t know what they have in common, one is an enemy parent BP (With no children yet) and 2 are projectiles.

Are you using any variant of ConstructorHelpers::FClassFinder or ConstructorHelpers::FObjectFinder ?

If the you are using set paths to objects or classes that are wrong (could have a mistype), it may hang unreal on load. Haven’t tried it during normal recompiles but it can be a culprit of engine hangs.

1 Like

I only work in Blueprint, so would that be the equivalent of “Get all actors of class”?
If so, I used to in an old version of those blueprints actually, in the construction script, but deleted them because i thought they were causing the hangs.

Edit: In fact, I deleted them because they would error horribly, add hundreds of empty items to the arrays, and just bug out uncontrollably, so I stopped using construction scripts like that altogether, you think there’s a remnant of that code somewhere in this BP?

Any type of getting actors should be called during or after begin play.

On construct works before other actors spawn in the world.

I have no more construction scripts running, I move them all to begin play after the bugs.
I only have one for a spawner that sets a box extent and some gizmos, but it doesn’t crash the engine.

Updated main post with some attempts.

I found the issue!
By taking a machete to my code, deleting functions en-masse, and slowly narrowing it down, I found the culprit.

DO NOT DO THIS ^

I really wish Unreal had a warning or even a regular crash screen instead of just an instant freeze, but oh well, live and learn.

Spawning can only occur during or after begin play. The constructor is called before the “World” exists to spawn in objects.

This was in the regular event graph, in a custom event, and not in the construction script.
The problem is when the “spawner” actor is destroyed, that reference is severed with no chance to recover.

Use this (Dramatic recreation) code to crash Unreal XD

You can actually do this if you cache your self class as a variable on begin play and then use it in the spawn :wink:

1 Like

Oh that’s interesting, what I ended up doing was - indeed - cache the class, but I passed it to a separate spawner BP via interface just to be extra safe.

image
This works well.

Edit: Since I learned something, you earned the “Solution” badge :smiley:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.