Cook Failure - Assertion Failed - !bDeletedThroughDeferredCleanup variable in MaterialShader.cpp

We are getting failure while packaging for regular x64 dekstop app,

There are warnings about different shaders that they are missing cached shader map

and errors about - Assertion Failed in MaterialShader.cpp, at 2139 line

void FMaterialShaderMap::AddRef()
{
	check(!bDeletedThroughDeferredCleanup);
	++NumRefs;
}

From what I’ve read in the comments of this structure its responsible for keeping track of material resources and its shader map,

So far we did:

  • Fixed redirectors,
  • Tried deleting Saved and Intermediate
  • Generated DDC data
  • we are looking through materials and material instances deleting loose nodes, looking for errors itd.
  • checking map, deleting unnecessary files from content browser and map
  • validated data

It’s on version 4.20 we’ve done quiet a lot of work already fixing up this error but still couldn’t overcome it
We would appreciate any help and suggestions on dealing with it.


Log from Cook.txt in appdata:

LogMaterial: Display: Missing cached shader map for material master_default_with_snow, compiling. 
LogMaterial: Display: Missing cached shader map for material master_landscape_spline_road, compiling. 
LogMaterial: Display: Missing cached shader map for material master_blend_m, compiling. 
LogShaderCompilers: Display: Shaders left to compile 2337
LogShaderCompilers: Display: Shaders left to compile 2327
LogShaderCompilers: Display: Shaders left to compile 2317
LogShaderCompilers: Display: Shaders left to compile 2307
LogWindows: Windows GetLastError: Operacja ukończona pomyślnie. (0)
LogShaderCompilers: Display: Shaders left to compile 2297
LogWindows: Error: begin: stack for UAT
LogWindows: Error: === Critical error: ===
LogWindows: Error: 
LogWindows: Error: Assertion failed: !bDeletedThroughDeferredCleanup [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\Materials\MaterialShader.cpp] [Line: 2139] 
LogWindows: Error: 
LogWindows: Error: 
LogWindows: Error: 
LogWindows: Error: [Callstack] 0x00007ffb0348a388 KERNELBASE.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffaf0026850 UE4Editor-ApplicationCore.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffada3a62fc UE4Editor-Core.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffada3351db UE4Editor-Core.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffac3c6d7a1 UE4Editor-Engine.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffac3c79e32 UE4Editor-Engine.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffac3c7ac2c UE4Editor-Engine.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffac3c7973c UE4Editor-Engine.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffac3c78061 UE4Editor-Engine.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffac3cc02da UE4Editor-Engine.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffac3cc060e UE4Editor-Engine.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffadc983345 UE4Editor-CoreUObject.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffadca6b7a1 UE4Editor-CoreUObject.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffadca862c4 UE4Editor-CoreUObject.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffadca854b9 UE4Editor-CoreUObject.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffad7110b3c UE4Editor-UnrealEd.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffad715553d UE4Editor-UnrealEd.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffad6fc7a8d UE4Editor-UnrealEd.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffad6ff88ff UE4Editor-UnrealEd.dll!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ff6a409e9c2 UE4Editor-Cmd.exe!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ff6a4095968 UE4Editor-Cmd.exe!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ff6a4095bba UE4Editor-Cmd.exe!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ff6a40a3dac UE4Editor-Cmd.exe!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ff6a40a4ce6 UE4Editor-Cmd.exe!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffb05793034 KERNEL32.DLL!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffb06671471 ntdll.dll!UnknownFunction []
LogWindows: Error: 
LogWindows: Error: end: stack for UAT
LogExit: Executing StaticShutdownAfterError
LogWindows: FPlatformMisc::RequestExit(1)
Log file closed, 12/14/18 16:47:40

Have you find any workaround ?

I had this problem too.

For me For me it comes from materials layers.
I need to force recompile the base material before each packaging

and i have to make sure there are no material instance that have the same combination of layers and layer blend.

Material instance 1: Layer A with Blend A | Background B

Material instance 2 : Layer A with Blend A | Background B

cause a crash


Material instance 1 : Layer A with Blend A | Background B

Material instance 2: Layer A with Copy Blend A | Background B

does not cause a crash.