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?