"UniformBufferRHI" Random Crash

Engine version is 4.24.3. I’ve been intermittently getting crashes with the following crash report:

Assertion failed: UniformBufferRHI.GetReference() [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\RenderCore\Public\UniformBuffer.h] [Line: 87] Attempted to access UniformBufferRHI on a TUniformBuffer that was never filled in with anything

And here’s the callstack from the logs:

[2020.07.08-20.39.42:502][829]LogWindows: Windows GetLastError: The operation completed successfully. (0)
[2020.07.08-20.39.42:503][829]LogWindows: Error: === Critical error: ===
[2020.07.08-20.39.42:503][829]LogWindows: Error: 
[2020.07.08-20.39.42:503][829]LogWindows: Error: Fatal error: [File:U:\UE_4.25_Source\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp] [Line: 855] 
[2020.07.08-20.39.42:503][829]LogWindows: Error: Rendering thread exception:
[2020.07.08-20.39.42:503][829]LogWindows: Error: Fatal error: [File:U:\UE_4.25_Source\Engine\Source\Runtime\Engine\Private\SceneManagement.cpp] [Line: 1131] 
[2020.07.08-20.39.42:503][829]LogWindows: Error: FMeshBatch was not properly setup. No primitive uniform buffer was specified and the vertex factory does not have a valid primitive id stream.
[2020.07.08-20.39.42:503][829]LogWindows: Error: 	VertexFactory[Name: FMeshParticleVertexFactory, Initialized: 1]
[2020.07.08-20.39.42:503][829]LogWindows: Error: 	PrimitiveSceneProxy[Level: /Game/Maps/PrototypeMap/UEDPIE_2_PrototypeMap, Owner: MGBulletProjectile_C_72, Resource: PS_ShotgunAndSMG_Projectile]
[2020.07.08-20.39.42:503][829]LogWindows: Error: 
[2020.07.08-20.39.42:503][829]LogWindows: Error: 
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd9882a799 KERNELBASE.dll!UnknownFunction []
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd5aeff0f6 UE4Editor-Core.dll!ReportAssert() [U:\UE_4.25_Source\Engine\Source\Runtime\Core\Private\Windows\WindowsPlatformCrashContext.cpp:1537]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd5aefb848 UE4Editor-Core.dll!FWindowsErrorOutputDevice::Serialize() [U:\UE_4.25_Source\Engine\Source\Runtime\Core\Private\Windows\WindowsErrorOutputDevice.cpp:78]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd5ac8ec4d UE4Editor-Core.dll!FOutputDevice::LogfImpl() [U:\UE_4.25_Source\Engine\Source\Runtime\Core\Private\Misc\OutputDevice.cpp:61]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd5865c288 UE4Editor-Engine.dll!FMeshBatch::PreparePrimitiveUniformBuffer() [U:\UE_4.25_Source\Engine\Source\Runtime\Engine\Private\SceneManagement.cpp:1123]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd586589e0 UE4Editor-Engine.dll!FMeshElementCollector::AddMesh() [U:\UE_4.25_Source\Engine\Source\Runtime\Engine\Private\SceneManagement.cpp:268]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd57cfcb16 UE4Editor-Engine.dll!FDynamicMeshEmitterData::GetDynamicMeshElementsEmitter() [U:\UE_4.25_Source\Engine\Source\Runtime\Engine\Private\Particles\ParticleSystemRender.cpp:1837]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd57cf9dfa UE4Editor-Engine.dll!FParticleSystemSceneProxy::GetDynamicMeshElements() [U:\UE_4.25_Source\Engine\Source\Runtime\Engine\Private\Particles\ParticleSystemRender.cpp:6934]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd49c4f248 UE4Editor-Renderer.dll!FSceneRenderer::GatherDynamicMeshElements() [U:\UE_4.25_Source\Engine\Source\Runtime\Renderer\Private\SceneVisibility.cpp:2918]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd49c4a8cc UE4Editor-Renderer.dll!FSceneRenderer::ComputeViewVisibility() [U:\UE_4.25_Source\Engine\Source\Runtime\Renderer\Private\SceneVisibility.cpp:4006]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd49c50577 UE4Editor-Renderer.dll!FDeferredShadingSceneRenderer::InitViews() [U:\UE_4.25_Source\Engine\Source\Runtime\Renderer\Private\SceneVisibility.cpp:4305]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd499122eb UE4Editor-Renderer.dll!FDeferredShadingSceneRenderer::Render() [U:\UE_4.25_Source\Engine\Source\Runtime\Renderer\Private\DeferredShadingRenderer.cpp:1376]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd49c20951 UE4Editor-Renderer.dll!RenderViewFamily_RenderThread() [U:\UE_4.25_Source\Engine\Source\Runtime\Renderer\Private\SceneRendering.cpp:3581]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd49c169b8 UE4Editor-Renderer.dll!TEnqueueUniqueRenderCommandType<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_4495dfbf235452f2a02310cb16370cef> >::DoTask() [U:\UE_4.25_Source\Engine\Source\Runtime\RenderCore\Public\RenderingThread.h:195]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd49c1751d UE4Editor-Renderer.dll!TGraphTask<TEnqueueUniqueRenderCommandType<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_4495dfbf235452f2a02310cb16370cef> > >::ExecuteTask() [U:\UE_4.25_Source\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:849]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd5aa1147f UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread() [U:\UE_4.25_Source\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:692]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd5aa11823 UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit() [U:\UE_4.25_Source\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:587]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd7ae5e352 UE4Editor-RenderCore.dll!RenderingThreadMain() [U:\UE_4.25_Source\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:341]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd7ae5e794 UE4Editor-RenderCore.dll!FRenderingThread::Run() [U:\UE_4.25_Source\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:473]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd5af1e37b UE4Editor-Core.dll!FRunnableThreadWin::Run() [U:\UE_4.25_Source\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86]
[2020.07.08-20.39.42:503][829]LogWindows: Error: [Callstack] 0x00007ffd5af1e1f4 UE4Editor-Core.dll!
[2020.07.08-20.39.42:503][829]LogWindows: Error: 
[2020.07.08-20.39.42:503][829]LogWindows: Error: 
[2020.07.08-20.39.42:520][829]LogExit: Executing StaticShutdownAfterError
[2020.07.08-20.39.42:525][829]LogWindows: FPlatformMisc::RequestExit(1)
[2020.07.08-20.39.42:525][829]LogCore: Engine exit requested (reason: Win RequestExit)
[2020.07.08-20.39.42:533][829]Log file closed, 07/08/20 14:39:42

I’ve never seen this error prior to 4.24. It happens most often while spawning particle systems, like projectile particles for my weapons. But it’s so intermittent that I have no idea what could be causing it… sometimes I can test play for half an hour, other times it happens after I’ve fired two bullets. Still other times it appears to happen when I spawn emitters for other effects.

Any ideas? Thanks!

After weeks of troubleshooting, modifying source code, and painstakingly trying to isolate anything I could possibly think of, I might be slightly closer to finding the problem. My observations so far…

→ The crash only seems to occur, or at least happens more quickly, when I’m playing with multiple clients (as opposed to a Listen Server and a client or just one client).

→ I tried out using different particles to see if it would stop the crash. I found one from a Marketplace content called “Action FX Pack.” The particle is called “Fire_Bullet,” and if I use it out-of-the-box with no changes, the crash seems to stop happening. However, if I start turning off certain emitters, the crash starts happening again.

I’m still working out which emitters exactly are causing the crash when I turn them off. It’s extremely odd to me that turning off emitters would cause this, but literally that’s the only difference between getting this crash and not at the moment…

Oh dear… well, I found the problem. My comment is irrelevant now, turns out I was treating symptoms rather than the root cause. A few months ago, I switched over to my Desktop computer to do the majority of the game work. One of the first things I did at that time was to set the Project Settings frame rate to be “Fixed” at 60, because I was getting over 100FPS on Desktop and I didn’t want that, so it seemed like a natural thing to do.

That’s what broke it. And of course because I use source control, everything carried over to my laptop, so I couldn’t isolate it that way which made it even more confusing. Setting to a Smooth Frame Rate with a range max of 60 has completely stopped the crashing.

I never want to look at or think about this again… but I’ve made a personal note to start tracking these kinds of global changes when I make them, because they’ll get you every time. I hope this helps someone with a similar problem in the future avoid any unnecessary stress!