Editor crash when hot-reloading code with Niagara enabled

Hello there,

I’ve just upgraded to 4.21 and decided to try Niagara. Created an emitter, a system and attached a NiagaraComponent to my character. Everything looks cool, but now every time when I try to recompile my project (with c++ through VS or Editor) Unreal Editor crashes…
Here is the stack trace:

Assertion failed: IsInGameThread() [File:D:\Build\++UE4\Sync\Engine\Plugins\FX\Niagara\Source\Niagara\Private\NiagaraCommon.cpp] [Line: 276]

UE4Editor_Core!FDebug::AssertFailed() [d:\build\++ue4\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:417]
UE4Editor_Niagara!FNiagaraScriptDataInterfaceCompileInfo::CanExecuteOnTarget() [d:\build\++ue4\sync\engine\plugins\fx\niagara\source\niagara\private\niagaracommon.cpp:277]
UE4Editor_Niagara!UNiagaraScript::CanBeRunOnGpu() [d:\build\++ue4\sync\engine\plugins\fx\niagara\source\niagara\private\niagarascript.cpp:1310]
UE4Editor_Niagara!UNiagaraScript::Serialize() [d:\build\++ue4\sync\engine\plugins\fx\niagara\source\niagara\private\niagarascript.cpp:335]
UE4Editor_HotReload!FAsyncTask<`FHotReloadModule::ReplaceReferencesToReconstructedCDOs'::`2'::FFindRefTask>::DoWork() [d:\build\++ue4\sync\engine\source\runtime\core\public\async\asyncwork.h:263]
UE4Editor_HotReload!FAsyncTask<`FHotReloadModule::ReplaceReferencesToReconstructedCDOs'::`2'::FFindRefTask>::DoThreadedWork() [d:\build\++ue4\sync\engine\source\runtime\core\public\async\asyncwork.h:288]
UE4Editor_Core!FQueuedThread::Run() [d:\build\++ue4\sync\engine\source\runtime\core\private\hal\threadingbase.cpp:455]
UE4Editor_Core!FRunnableThreadWin::Run() [d:\build\++ue4\sync\engine\source\runtime\core\private\windows\windowsrunnablethread.cpp:76]

Maybe I’ve missed something… Can someone help me, please?
P.S. With 4.20 there is the same issue.

I’ve had this since 4.20 as well. In addition it causes an error when cooking content:

UATHelper: Cooking (Windows):   LogWindows: Error: begin: stack for UAT
UATHelper: Cooking (Windows):   LogWindows: Error: === Critical error: ===
UATHelper: Cooking (Windows):   LogWindows: Error:
UATHelper: Cooking (Windows):   LogWindows: Error: Fatal error: [File:C:\Unreal Engine\UnrealEngine\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 305]
UATHelper: Cooking (Windows):   LogWindows: Error: Illegal call to StaticFindObject() while serializing object data!
UATHelper: Cooking (Windows):   LogWindows: Error:
UATHelper: Cooking (Windows):   LogWindows: Error:
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd5b0aa388 KERNELBASE.dll!UnknownFunction []
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd2e3770ca UE4Editor-Core.dll!FWindowsErrorOutputDevice::Serialize() [c:\unreal engine\unrealengine\engine\source\runtime\core\private\windows\windowserroroutputdevice.cpp:63]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd2e15a4e7 UE4Editor-Core.dll!FOutputDevice::LogfImpl() [c:\unreal engine\unrealengine\engine\source\runtime\core\private\misc\outputdevice.cpp:71]
PackagingResults: Error: begin: stack for UAT
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd2e093147 UE4Editor-Core.dll!FDebug::AssertFailed() [c:\unreal engine\unrealengine\engine\source\runtime\core\private\misc\assertionmacros.cpp:417]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd2ec9cf81 UE4Editor-CoreUObject.dll!StaticFindObject() [c:\unreal engine\unrealengine\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:308]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcfbf3ef20 UE4Editor-NiagaraShader.dll!FNiagaraDataInterfaceParamRef::InitDIClass() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagarashader\private\niagarashader.cpp:1338]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcfbf2ed11 UE4Editor-NiagaraShader.dll!operator<<() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagarashader\private\niagarashader.cpp:1369]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcfbf2ec10 UE4Editor-NiagaraShader.dll!operator<<() [c:\unreal engine\unrealengine\engine\source\runtime\core\public\containers\array.h:1100]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcfbf50179 UE4Editor-NiagaraShader.dll!FNiagaraShader::Serialize() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagarashader\private\niagarashader.cpp:1284]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd33233d67 UE4Editor-ShaderCore.dll!FShader::SerializeBase() [c:\unreal engine\unrealengine\engine\source\runtime\shadercore\private\shader.cpp:1015]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcfbf50e25 UE4Editor-NiagaraShader.dll!TShaderMap<FNiagaraShaderType>::SerializeInline() [c:\unreal engine\unrealengine\engine\source\runtime\shadercore\public\shader.h:1892]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcfbf503f4 UE4Editor-NiagaraShader.dll!FNiagaraShaderMap::Serialize() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagarashader\private\niagarashader.cpp:1103]
PackagingResults: Error: === Critical error: ===
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcfbf3f8b0 UE4Editor-NiagaraShader.dll!FNiagaraShaderMap::LoadFromDerivedDataCache() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagarashader\private\niagarashader.cpp:466]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcfbf364c6 UE4Editor-NiagaraShader.dll!FNiagaraShaderScript::CacheShaders() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagarashader\private\niagarashared.cpp:275]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcfbf36c94 UE4Editor-NiagaraShader.dll!FNiagaraShaderScript::CacheShaders() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagarashader\private\niagarashared.cpp:257]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcf4e13710 UE4Editor-Niagara.dll!UNiagaraScript::CacheShadersForResources() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagara\private\niagarascript.cpp:993]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcf4e1333d UE4Editor-Niagara.dll!UNiagaraScript::CacheResourceShadersForCooking() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagara\private\niagarascript.cpp:975]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffcf4e10ed3 UE4Editor-Niagara.dll!UNiagaraScript::BeginCacheForCookedPlatformData() [c:\unreal engine\unrealengine\engine\plugins\fx\niagara\source\niagara\private\niagarascript.cpp:943]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd2ec1558f UE4Editor-CoreUObject.dll!UPackage::Save() [c:\unreal engine\unrealengine\engine\source\runtime\coreuobject\private\uobject\savepackage.cpp:3848]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd08f20387 UE4Editor-UnrealEd.dll!UEditorEngine::Save() [c:\unreal engine\unrealengine\engine\source\editor\unrealed\private\editorengine.cpp:4441]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd08dc2b3b UE4Editor-UnrealEd.dll!UCookOnTheFlyServer::SaveCookedPackage() [c:\unreal engine\unrealengine\engine\source\editor\unrealed\private\cookontheflyserver.cpp:3988]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd08dc5361 UE4Editor-UnrealEd.dll!UCookOnTheFlyServer::SaveCookedPackages() [c:\unreal engine\unrealengine\engine\source\editor\unrealed\private\cookontheflyserver.cpp:2896]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd08dd0612 UE4Editor-UnrealEd.dll!UCookOnTheFlyServer::TickCookOnTheSide() [c:\unreal engine\unrealengine\engine\source\editor\unrealed\private\cookontheflyserver.cpp:2372]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd08c33e1b UE4Editor-UnrealEd.dll!UCookCommandlet::CookByTheBook() [c:\unreal engine\unrealengine\engine\source\editor\unrealed\private\commandlets\cookcommandlet.cpp:882]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd08c65edf UE4Editor-UnrealEd.dll!UCookCommandlet::Main() [c:\unreal engine\unrealengine\engine\source\editor\unrealed\private\commandlets\cookcommandlet.cpp:586]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ff73bbedf15 UE4Editor-Cmd.exe!FEngineLoop::PreInit() [c:\unreal engine\unrealengine\engine\source\runtime\launch\private\launchengineloop.cpp:2478]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ff73bbe4ae2 UE4Editor-Cmd.exe!GuardedMain() [c:\unreal engine\unrealengine\engine\source\runtime\launch\private\launch.cpp:135]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ff73bbe4d2a UE4Editor-Cmd.exe!GuardedMainWrapper() [c:\unreal engine\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:145]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ff73bbf3aaa UE4Editor-Cmd.exe!WinMain() [c:\unreal engine\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:276]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ff73bbf4a16 UE4Editor-Cmd.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd5d453034 KERNEL32.DLL!UnknownFunction []
UATHelper: Cooking (Windows):   LogWindows: Error: [Callstack] 0x00007ffd5e081471 ntdll.dll!UnknownFunction []
UATHelper: Cooking (Windows):   LogWindows: Error:
UATHelper: Cooking (Windows):   LogWindows: Error: end: stack for UAT

Still occurring in 4.21 … In my case, I’ve been able to confirm that it is caused by a Particle System asset. I can use my version control to switch between a previous and current revision of a Particle System and with the previous revision, I can hot reload OK. I am still trying to figure out what’s different in the new one to see if I can reproduce this reliably with any Particle System. Further, I can remove all emitters from the system so it is completely empty and does nothing, and it still crashes the hot reload. Feels like a form of uasset corruption.

Disabling async level streaming solved this issue for me:

I have async loading off and still have the issue

I have the same error when activating GPU system in the emitter. Once the asset is loaded the error will occur at the next hot reloading. Close it or delete it doesn’t prevent the error, you have to close the project and restart it without opening the asset to be able to hot reload.

Disabling GPU doesn’t suppress the error. The asset seems to keep some state that trigger the error.

Emitters with CPU work for me.

This prevent me to use niagara, very annoying !

The async loading thing didn’t help me either.
Still happening in 4.21.2! Why isn’t there more uproar about this? It’s murdering iteration times. Is there a bug for this registered somewhere? Are people not using niagara? Or big dev houses have a local fix? Is there a workaround other than pulling the engine from git and using an older version? ( though we’re excited about new niagara updates )

There is a similar bug, and it seems Epic Games are not interested in development on C++, only Blueprints.

I’ve been dealing with it for months now. I really shouldn’t have jumped on the niagara ship so fast

I have the same issue and I didn’t manage to reproduc it in a blank project… Did someone have any clue why ?
I already try to cleanup all my project folders (.sln, intermediate, binaries, …) without success.

(I need a way to reproduce it if I want to report the issue …)


Edit : I managed to found the reproducing steps thanks to @ShannonGreenwood using “GPUSim” in the emitter and send it to Unreal Support. I’m now waiting for their answers and/or the creation of the issue.


Update : I received an answer from the Unreal support :

“While I was able to reproduce your crash with your project, I have also confirmed that this issue no longer occurs in future versions of the engine. Please stay tuned for future updates.”

Did you try to create not just a blank project, but from any C++ template and make some changes in the code?

Unfortunatly yes!
I even tried to copy all my C++ classes, used same plugins and copied settings files (.ini) in the fresh blank C++ project. I’m still trying but no success, I can’t figure it out! First time i’m hopping the engine crash…

submitted a bug before I figured out how to reproduce - I don’t know how to find that bug now? Should I be able to search for it? Should I have gotten an email about it?

To repro:
have gpu sim enabled on a niagara emitter and c++ hotloading will crash

Yesterday - I tried migrating all of my niagara systems into an empty project - maybe the offending niagara emitters weren’t loaded and the crash didn’t happen. When I changed one of the emitter to gpu sim today, I started getting the crash.

You’re right!
I just changed the emitter to “GPU sim” and use the “Full rebuild” then “Compile” and it crashed.
I was able to send the reproducing steps to unreal thanks to you!

I’ve commented out the checks and things no longer crash. We’re going to try this workaround and see if it causes any issues.

bool FNiagaraScriptDataInterfaceCompileInfo::CanExecuteOnTarget(ENiagaraSimTarget SimTarget) const
{
	//hack hack, this is causing issues when hotloading - hopefully epic fixes it soon
	//check(IsInGameThread());
	UNiagaraDataInterface* Obj = GetDefaultDataInterface();
	if (Obj)
	{
		return Obj->CanExecuteOnTarget(SimTarget);
	}
	check(false);
	return false;
}

UNiagaraDataInterface* FNiagaraScriptDataInterfaceCompileInfo::GetDefaultDataInterface() const
{
	//hack hack, this is causing issues when hotloading - hopefully epic fixes it soon
	//check(IsInGameThread());
	UNiagaraDataInterface* Obj = CastChecked<UNiagaraDataInterface>(const_cast<UClass*>(Type.GetClass())->GetDefaultObject(true));
	return Obj;
}

It may work, but I’m pretty sure it’s here to prevent some Access Violation from this thread to the game thread. But it seems fair to trade an every time crash with an eventual crash.

I received an answer from the Unreal support :

“While I was able to reproduce your crash with your project, I have also confirmed that this issue no longer occurs in future versions of the engine. Please stay tuned for future updates.”

What file are you changing here?

Sorry. I should have been more specific.
I changed the file here C:\Program Files\Epic Games\UE_4.21\Engine\Plugins\FX\Niagara\Source\Niagara\Private
But it’s not doing anything. The error message still refers to a file. D:\Build\++UE4\Sync\Engine\Plugins\FX\Niagara\Source\Niagara\Private\NiagaraCommon.cpp but I dont have a d drive

NiagaraCommon.cpp