Long Stutter Loading Niagara Systems after Upgrading to Newest UE5

Recently upgraded from the old UE5 preview version to latest. Whenever I launch the editor I see a bunch of printouts like this:

LogNiagara: Compiling System NiagaraSystem FX/Melee_Slash/Hit/NS_Sword_Hit_SlashLine.NS_Sword_Hit_SlashLine took 0.118195 sec, no shader worker used

Some of these Niagara Systems are loading during game runtime. (in the editor, after pressing play) When that happens I see similar messages and there is a very noticeable stutter - maybe a 1/3rd of a second pause. In that case the Niagara System is loaded from a soft object ptr, so it’s not compiled at editor startup.

In the prev verions of UE5 we also loaded these assets via soft ptr but there wasn’t a noticeable stutter and I don’t remember seeing the NSystem recompilation messages.

My issue is similar to this old thread: Niagara Systems Always Recompiling In Editor

In my case it also seems like NiagaraScript::AreScriptAndSourceSynchronized() is returning false constantly and forcing systems to rebuild each time instead of using a cached version.

I tried re-compiling and re-saving the systems, didn’t help. Has anyone run into this? Should I be seeing these messages every time? It seems like something is somehow misconfigured.

Edit: Little more information on the problem:

It seems like when I run the editor and it compiles a particle system bCompileForEdit in the system is false, and because of that use rapid iteration is false. (It is compiling for max performance) But when I compile / save from the Niagara editor it’s in bCompileForEdit mode so it’s saving out with rapid iteration true. So the end result is that the cached version is never matching because it’s cached as the rapid iteration version but it’s compiling in-game as the non-rapid version.

This commented out line “fixes” the issue:

void FNiagaraSystemViewModel::Initialize(UNiagaraSystem& InSystem, FNiagaraSystemViewModelOptions InOptions)
{
	System = &InSystem;
	// System->bCompileForEdit = true;

Edit2: I have a messy fix for now:

	if (System)
	{
		System->bCompileForEdit = false;

		//force recompile so that it's not in compile for edit mode
		CompileSystem(true);
		System->OnSystemPostEditChange().Remove(SystemChangedDelegateHandle);
	}

I added the CompileSystem line - the idea is when you close the niagara system editor it forces a recompile now that bCompileForEdit is false. Not perfect (when if you exit unreal with editor open?) but it’s better at least? Really not sure if this is intended behavior or a logical bug or what, but it feels like a reversion from UE5 preview where I didn’t get these hitches the first time I loaded an effect in game, presumable because something about the bCompileForEdit and related settings (rapid iteration etc) was handled differently.

It seems to me that you’d never want to cache the bCompileForEdit version of the system to disk, since compile for edit seems specific to using the editor. You want the editor to use a version that is compiled for edit (since that makes the editor more performant?) but want to save out the non-rapid-iteration version?

5 Likes

Unfortunately this is still an issue in 5.0.3. Niagara systems recompiling were adding 40 seconds to our editor startup time. Resaving them doesn’t really fix the issue since the next time someone edits the system it will be broken again.

I think the easiest way to fix this would be to make bCompileForEdit just always false. I’m not sure how badly that would bork the Niagara editor performance though. My understanding is that the flag exists so that using the niagara editor window is snappier - if the performance of the particle editor is still acceptable even when bCompileForEdit is off I would just make it off permanently.

Alternately, you could make the editor (non cooked) version load the edit versions rather than cooked versions - it’s been a little while since I looked at it so that might be a bit trickier.

make bCompileForEdit just always false

Yea, that’s what I ended up doing. I asked our VFX guy to see if it caused any noticeable problems. He hasn’t complained yet, so maybe it’s a workable temporary solution.

Thanks a bunch for posting this. It saved me a fair bit of digging.

1 Like

Same issue here!

Let’s see if someone can bring some light into this.

This is still happening in 5.1.

LogNiagara: Compiling System NiagaraSystem /Game/UltraDynamicSky/Particles/Rain.Rain took 19.474464 sec (time since issued), 2.323039 sec (combined shader worker time).
LogNiagara: Compiling System NiagaraSystem /Game/UltraDynamicSky/Particles/Snow.Snow took 19.400925 sec (time since issued), 26.025091 sec (combined shader worker time).

I have locally re-saved every Niagara System in the project, didn’t help either.

Confirmed still happening in 5.1.

The suggested fix of System->bCompileForEdit = false does not work in 5.1 (Lyra project). It still always spends 30 seconds doing this same dumb repetitive nonsense every time I start the editor.

LogNiagara: Compiling System NiagaraSystem /Game/Effects/Particles/Environmental/NS_CharacterDash.NS_CharacterDash took 29.178122 sec, no shader worker used.
LogNiagara: Compiling System NiagaraSystem /Game/Effects/Particles/Impacts/NS_DeathCubes.NS_DeathCubes took 29.041485 sec, no shader worker used.
LogNiagara: Compiling System NiagaraSystem /Game/Effects/Particles/Environmental/NS_ElectricMovement.NS_ElectricMovement took 28.778368 sec, no shader worker used.
1 Like

FWIW this seems to be fixed in UE 5.2.

1 Like

Huzzah - the changes I suggested above did work for me but the workflow was so impractical (have to close a system, wait a second, then save it again) that it wasn’t much of a solution.