# Engine crashes when stop simulating while a dynamic material instance is being set to a sprite component

**URL:** <https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, crash, bug-report, question\
**Created:** [November 18, 2023, 2:28am UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441 "2023-11-18T02:28:21Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![RodrigoFMello11](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RodrigoFMello11](https://forums.unrealengine.com/u/RodrigoFMello11)\
**Post date:** [November 18, 2023, 2:28am UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/1 "2023-11-18T02:28:21Z")

</div>

Hello, I’m using UE 5.3.2 and I’m experiencing an issue in which if you stop simulating (press ESC), while set a parameter of a dynamic material instance in event tick (or in a timeline, or quick timer), the engine crashes, here is the log (with symbols installed):

```auto
Assertion failed: Index>=0 && Index<NumBits [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Containers\BitArray.h] [Line: 1418]

UnrealEditor_Core!FOutputDeviceRedirector::Panic() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Misc\OutputDeviceRedirector.cpp:773]
UnrealEditor_Core!ReportCrash() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsPlatformCrashContext.cpp:1610]
UnrealEditor_RenderCore!`FRenderingThread::Run'::`1'::filt$0() [D:\build\++UE5\Sync\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:539]
VCRUNTIME140
ntdll
ntdll
ntdll
UnrealEditor_Engine!FMaterialRenderProxy::UpdateDeferredCachedUniformExpressions() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Materials\MaterialRenderProxy.cpp:680]
UnrealEditor_Renderer!FScene::UpdateAllPrimitiveSceneInfos() [D:\build\++UE5\Sync\Engine\Source\Runtime\Renderer\Private\RendererScene.cpp:5356]
UnrealEditor_Engine!FSceneInterface::UpdateAllPrimitiveSceneInfos() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\SceneInterface.cpp:17]
UnrealEditor_Renderer!TEnqueueUniqueRenderCommandType<`FScene::Release'::`2'::FReleaseCommandName,`FScene::Release'::`2'::<lambda_3> >::DoTask() [D:\build\++UE5\Sync\Engine\Source\Runtime\RenderCore\Public\RenderingThread.h:209]
UnrealEditor_Renderer!TGraphTask<TEnqueueUniqueRenderCommandType<`FScene::Release'::`2'::FReleaseCommandName,`FScene::Release'::`2'::<lambda_3> > >::ExecuteTask() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:1265]
UnrealEditor_Core!FNamedTaskThread::ProcessTasksNamedThread() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:758]
UnrealEditor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:649]
UnrealEditor_RenderCore!RenderingThreadMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:411]
UnrealEditor_RenderCore!FRenderingThread::Run() [D:\build\++UE5\Sync\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:537]
UnrealEditor_Core!FRunnableThreadWin::Run() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:149]

```

Some notes:

- I’ve Already reinstalled the engine and visual studio

- It only seems to happen with sprite components, trying the same with a static mesh component for exemple do not have this issue

Launching the project in debug mode with visual studio, the first breakpoint of the crash happens in this file and function:

```auto
File: MaterialRenderProxy.cpp

Function: (Line 659)void FMaterialRenderProxy::UpdateDeferredCachedUniformExpressions()

Line: (Line 683) const FMaterial* Material = MaterialProxy->GetMaterialNoFallback(InFeatureLevel);

```

Steps to reproduce in a clean project:

- Create a new actor an add a Sprite Component

- On Begin Play create a dynamic material instance and set the sprite material

- On Tick (or in a timeline, or quick timer) set a parameter of the Dynamic Material

- Place the Actor in the Level and Play

- Stop Simulating (Press Esc)

Sometimes it will take a couple of attempts for the crash to happen, sometimes it will be first try.

Any help or workaroud will be highly apreciated, as this is greatly slowing the development of my project. Thanks.

---

<div class="post-metadata">

**Author:** ![SupportiveEntity](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupportiveEntity](https://forums.unrealengine.com/u/SupportiveEntity)\
**Post date:** [November 20, 2023, 9:00am UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/2 "2023-11-20T09:00:52Z")

</div>

Hey there @RodrigoFMello11! Welcome to the community! It’s reproducible with only sprites it seems. Other materials don’t seem to cause it, and it’s still yet inconsistent with sprites. Looks like a bug, you can report those here:

> **[Report a Bug](https://www.unrealengine.com/en-US/support/report-a-bug)**
>
> Unreal Engine is the world’s most open and advanced real-time 3D creation platform for photoreal visuals and immersive experiences.

---

<div class="post-metadata">

**Author:** ![RodrigoFMello11](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RodrigoFMello11](https://forums.unrealengine.com/u/RodrigoFMello11)\
**Post date:** [November 24, 2023, 12:39am UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/3 "2023-11-24T00:39:51Z")

</div>

Thanks, I’ve reported the bug. But since it is related to Paper2D I don’t expect it to be fixed any time soon. So if someone have a workaround I would be very thankful, as this issue is greatly slowing the development of my project

---

<div class="post-metadata">

**Author:** ![ChronoYuki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chronoyuki/32/470393_2.png) [@ChronoYuki](https://forums.unrealengine.com/u/ChronoYuki)\
**Post date:** [January 5, 2024, 11:26am UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/4 "2024-01-05T11:26:45Z")

</div>

Have same issue. UE 5.3.2, Paper2D, Not the dymanic material instance but “Set material parameter” to change color of a Paper2D Sprite. Engine crash randomly after quitting PIE preview. seems it will crash when you quitting and a parameter changed in same tick.

Scratching my head for days and still have no solution. Dev guys should really fit some Paper2D bugs. Reported and waiting.

For me it just crash in engine, standalone or build game are stable without problem, But still very annoying at working.

---

<div class="post-metadata">

**Author:** ![ishii\_zereo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ishii\_zereo](https://forums.unrealengine.com/u/ishii_zereo)\
**Post date:** [January 26, 2024, 4:10pm UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/5 "2024-01-26T16:10:55Z")

</div>

By inserting the C++ code below into the EndPlay function of a certain class, the crash no longer occurs.

```auto
#include "Materials/MaterialRenderProxy.h"

void ASampleViewer::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
	Super::EndPlay(EndPlayReason);

#if WITH_EDITOR
	if (EndPlayReason == EEndPlayReason::EndPlayInEditor)
	{
		FUniformExpressionCacheAsyncUpdateScope AsyncUpdateScope;
	}
#endif
}

```

There is no doubt that this is not the correct way to deal with it, but I have found a way to avoid it as a workaround, so I would like to share it with you.

---

<div class="post-metadata">

**Author:** ![8bitSami](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@8bitSami](https://forums.unrealengine.com/u/8bitSami)\
**Post date:** [February 29, 2024, 4:12pm UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/6 "2024-02-29T16:12:03Z")

</div>

Sorry for bringing this back up, but does anyone have any idea of how this might be resolved in Blueprints? Like OP, it seems to only have started occurring when I added an emissive color to a custom sprite material that is applied to a Paper2d sprite.

I’m so glad I found this forum post as I can at least disable the effect for now, but I would love to implement it back in if possible.

What is interesting is it would crash even if I didn’t trigger the emissive color.

Any suggestions on how I might be able to implement the same C++ workaround but in BP?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![SupportiveEntity](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupportiveEntity](https://forums.unrealengine.com/u/SupportiveEntity)\
**Post date:** [March 1, 2024, 9:53am UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/7 "2024-03-01T09:53:49Z")

</div>

Hey there @8bitSami! Welcome to the community! Unfortunately this workaround is only viable using C++ as it would have to be injected into the base class itself.

---

<div class="post-metadata">

**Author:** ![RodrigoFMello11](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RodrigoFMello11](https://forums.unrealengine.com/u/RodrigoFMello11)\
**Post date:** [March 1, 2024, 1:50pm UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/8 "2024-03-01T13:50:10Z")

</div>

Thanks, going to try it, although none of my class are C++ based, it is worth converting them to C++, since this problem is really slowing the development of the project. Hopefuly this will be solved in UE 5.4

---

<div class="post-metadata">

**Author:** ![surmounter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@surmounter](https://forums.unrealengine.com/u/surmounter)\
**Post date:** [April 7, 2024, 1:49pm UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/9 "2024-04-07T13:49:10Z")

</div>

Thanks! You saved my life!!

---

<div class="post-metadata">

**Author:** ![KennyTeo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KennyTeo](https://forums.unrealengine.com/u/KennyTeo)\
**Post date:** [June 15, 2024, 9:04am UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/10 "2024-06-15T09:04:51Z")

</div>

I have 0 experience in C++, and have no idea what this code does, so pardon me if I am asking something that does not make sense.

Is it possible for me to include an object that just runs this code and nothing else to mitigate the issue?

---

<div class="post-metadata">

**Author:** ![KennyTeo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KennyTeo](https://forums.unrealengine.com/u/KennyTeo)\
**Post date:** [June 15, 2024, 1:59pm UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/11 "2024-06-15T13:59:52Z")

</div>

Leaving this here so that poor souls like me who know nothing about C++ can implement the proposed workaround.  
Huge Disclaimer: I know nothing about C++, so use it at your own risk.

Steps to implement proposed workaround:

1. Tools \> New C++Class
2. Name it as SampleViewer (I chose this name because of proposed solution)
3. Use Actor Class as base
4. In SampleViewer.cpp,  
4.1 Add `#include "Materials/MaterialRenderProxy.h"` below `#include "SampleViewer.h"`  
4.2 Paste the rest of the code below BeginPlay()  
4.3 Visual Studio will prompt you to create EndPlay() in SampleView.h. Use it.  
4.4 Check out the screenshots if these are too confusing
5. Save
6. In Unreal Engine Editor, recompile
7. Create new Blueprint Class  
7.1 Under ALL CLASSES, select newly created SampleViewer  
7.2 Place it anywhere in the Editor

It seems to work fine so far, so kudos to the solution.

Below is what the end result looks like in code:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/4/0/540ef244db8099ee1cd394882ccf93696d68761e.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/1/4311bd96b530e56b449dedb437653f19e76202dd.png)

---

<div class="post-metadata">

**Author:** ![Kirtasher](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kirtasher](https://forums.unrealengine.com/u/Kirtasher)\
**Post date:** [September 21, 2024, 1:19pm UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/12 "2024-09-21T13:19:03Z")

</div>

For those who don’t want to have to touch anything in C++, the solution is quite quick and practical. Include a hotkey in the project (it can be ESC) and make a call to the QUIT GAME event. It works perfectly and doesn’t crash. It’s just as fast as stopping the simulation, at most it takes a few milliseconds longer.

---

<div class="post-metadata">

**Author:** ![GokuLoganJr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GokuLoganJr](https://forums.unrealengine.com/u/GokuLoganJr)\
**Post date:** [May 26, 2025, 1:42pm UTC](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441/13 "2025-05-26T13:42:19Z")

</div>

Thanks @Kirtasher  
This helped a lot.
