Crash in UNiagaraDataInterfaceStaticMesh when cloning BP containing Niagara FX

Good afternoon,

We have a Niagara system (NSY_Fire_Zone), which uses parent static mesh to distribute the particles:

[Image Removed]This setup works as expected unless we try to clone the object. I am using Alt+Drag on gizmo with actor selected, but it’s not 100% related to gizmo, regular Copy-Paste can crash too.

Apparently that behavior if not crashing the editor can leave actors in “broken” state, so Editor will crash on Level Load with same callstack.

We noted that on some PCs with more performant hardware crash occurs less. On my Ryzen 7950X + RTX 4080 it crashes almost always. Sometimes crash occurs after couple of frames after clone is performed, so I could assume it’s some kind of timing issue.

Crash does not occur when Niagara is set to CPU sim, but we need to use GPU sim because of performance considerations.

Crash does not occur when Niagara System is standalone (e.g. not a part of a Blueprint).

Crash seems to not occur in UE 5.8.1. At least I was able to clone & reload level ~ 20 times with no issues. Sadly we cannot upgrade our project to UE 5.8.1 now and I was not able to spot the CL which mentions such a problem.

Appreciate if you can point me out to CL to cherry-pick. If you spot another problems with our setup, please let me know as well

Cheers,

Bohdan

[Attachment Removed]

Steps to Reproduce

  1. Load LVL_FXTest level
  2. Select BP_ActorWithFX placed
  3. Clone BP by using Alt+Mouse drag
  4. Observe crash
    [Attachment Removed]

Repro project

and callstack

[UnrealEditor-Niagara.dll] TMapBase<unsigned __int64,NDIStaticMeshLocal::FInstanceData_RenderThread,FDefaultSetAllocator,TDefaultMapHashableKeyFuncs<unsigned __int64,NDIStaticMeshLocal::FInstanceData_RenderThread,0> >::FindChecked(const unsigned long long) Map.h.inl:648
[UnrealEditor-Niagara.dll] UNiagaraDataInterfaceStaticMesh::SetShaderParameters(const FNiagaraDataInterfaceSetShaderParametersContext &) NiagaraDataInterfaceStaticMesh.cpp:3141
[UnrealEditor-Niagara.dll] FNiagaraGpuComputeDispatch::SetDataInterfaceParameters(FRDGBuilder &, const FNiagaraGPUSystemTick &, const FNiagaraComputeInstanceData &, const TShaderRefBase<…> &, const FNiagaraSimStageData &, const FNiagaraShaderScriptParametersMetadata &, unsigned char *) NiagaraGpuComputeDispatch.cpp:2513
[UnrealEditor-Niagara.dll] FNiagaraGpuComputeDispatch::DispatchStage(FRDGBuilder &, const FNiagaraGPUSystemTick &, const FNiagaraComputeInstanceData &, const FNiagaraSimStageData &) NiagaraGpuComputeDispatch.cpp:1705
[UnrealEditor-Niagara.dll] FNiagaraGpuComputeDispatch::ExecuteTicks(FRDGBuilder &, TStridedView<…>, Type) NiagaraGpuComputeDispatch.cpp:1303
[UnrealEditor-Niagara.dll] FNiagaraGpuComputeDispatch::PostRenderOpaque(FRDGBuilder &, TStridedView<…>, FSceneUniformBuffer &, bool) NiagaraGpuComputeDispatch.cpp:2168
[UnrealEditor-Engine.dll] FFXSystemSet::PostRenderOpaque(FRDGBuilder &, TStridedView<…>, FSceneUniformBuffer &, bool) FXSystemSet.cpp:201
[UnrealEditor-Renderer.dll] RenderOpaqueFX(FRDGBuilder &, TStridedView<…>, FSceneUniformBuffer &, FFXSystemInterface *, Type, TRDGUniformBuffer<…> *) DeferredShadingRenderer.cpp:602
[UnrealEditor-Renderer.dll] FDeferredShadingSceneRenderer::Render(FRDGBuilder &, const FSceneRenderUpdateInputs *) DeferredShadingRenderer.cpp:3565
[UnrealEditor-Renderer.dll] RenderViewFamily_RenderThread(FRDGBuilder &, FSceneRenderer *, const FSceneRenderUpdateInputs *) SceneRendering.cpp:4909
[Inlined] [UnrealEditor-Renderer.dll] FRendererModule::BeginRenderingViewFamilies::__l116::<lambda_4>::operator()(FRDGBuilder &, const FSceneRenderFunctionInputs &) SceneRendering.cpp:5207
[UnrealEditor-Renderer.dll] `FRendererModule::BeginRenderingViewFamilies'::`116'::<lambda_4>::<lambda_invoker_cdecl>(FRDGBuilder &,const FSceneRenderFunctionInputs &) SceneRendering.cpp:5209
[Inlined] [UnrealEditor-Renderer.dll] UE::Core::Private::Function::TFunctionRefBase::operator()(FRDGBuilder &, const FSceneRenderFunctionInputs &) Function.h:414
[UnrealEditor-Renderer.dll] `FSceneRenderProcessor::Execute'::`30'::<lambda_4>::operator()(FRHICommandListImmediate &) SceneRenderBuilder.cpp:891
[UnrealEditor-RenderCore.dll] ExecuteCommand(FRHICommandList *, const TVariant<…> &, const FRenderCommandTag &) RenderingThread.cpp:1540
[Inlined] [UnrealEditor-RenderCore.dll] FRenderThreadCommandPipe::ExecuteCommands::__l2::<lambda_1>::operator()(TVariant<…> &&, const FRenderCommandTag &) RenderingThread.cpp:1937
[UnrealEditor-RenderCore.dll] UE::RenderCommandPipe::FCommandList::ConsumeCommands<`FRenderThreadCommandPipe::ExecuteCommands'::`2'::<lambda_1> >(const <lambda_1> &) RenderingThread.h:430
[Inlined] [UnrealEditor-RenderCore.dll] FRenderThreadCommandPipe::ExecuteCommands(UE::RenderCommandPipe::FCommandList &) RenderingThread.cpp:1935
[UnrealEditor-RenderCore.dll] `FRenderThreadCommandPipe::EnqueueAndLaunch'::`5'::<lambda_1>::operator()() RenderingThread.cpp:1922
[Inlined] [UnrealEditor-RenderCore.dll] UE::Core::Private::Function::TFunctionRefBase::operator()() Function.h:414
[Inlined] [UnrealEditor-RenderCore.dll] TFunctionGraphTaskImpl::DoTaskImpl(TUniqueFunction<…> &, Type, const TRefCountPtr<…> &) TaskGraphInterfaces.h:1101
[Inlined] [UnrealEditor-RenderCore.dll] TFunctionGraphTaskImpl::DoTask(Type, const TRefCountPtr<…> &) TaskGraphInterfaces.h:1094
[UnrealEditor-RenderCore.dll] TGraphTask::ExecuteTask() TaskGraphInterfaces.h:696
[UnrealEditor-Core.dll] UE::Tasks::Private::FTaskBase::TryExecuteTask() TaskPrivate.h:518
[Inlined] [UnrealEditor-Core.dll] FBaseGraphTask::Execute(TArray<…> &, Type, bool) TaskGraphInterfaces.h:495
[UnrealEditor-Core.dll] FNamedTaskThread::ProcessTasksNamedThread(int, bool) TaskGraph.cpp:791
[UnrealEditor-Core.dll] FNamedTaskThread::ProcessTasksUntilQuit(int) TaskGraph.cpp:679
[UnrealEditor-RenderCore.dll] RenderingThreadMain(FEvent *) RenderingThread.cpp:260
[UnrealEditor-RenderCore.dll] FRenderingThread::Run() RenderingThread.cpp:418
[UnrealEditor-Core.dll] FRunnableThreadWin::Run() WindowsRunnableThread.cpp:156
[UnrealEditor-Core.dll] FRunnableThreadWin::GuardedRun() WindowsRunnableThread.cpp:71

[Attachment Removed]

Hi there,

Apologies for the delay. The fix for the crash involves a couple changelists:

CL#50361227 (d0851e) Be sure to destroy simulation instances in PostApplyToComponent to reflect the fact that the instance parameters could be changed out from under us and our DI bindings could go stale

CL#51269735 (6c6f89) - Add optional reactivate to PostApplyToComponent

- Add optional reactivate to PostApplyToComponent

- When inside the BP window activating a component that isn’t activated by default in the parent blueprint will go inactivate after the first frame due to PostToApply

- The new reactivation can be disabled with fx.Niagara.Rollback.AllowReactivateInPostApplyToComponent in case we run into issues with parameter stores and dirty data

After moving the BP there’s an error LogNiagara: StaticMesh data interface has no valid mesh, because no mesh is assigned inside BP_ActorWithFX

Hope this helps!

[Attachment Removed]

Thanks. That fixes the issue!

Best regards

[Attachment Removed]