Shipping Build Crahes in DX12, but is fine in DX11. UE5.4.4

Hey Everyone

I built a shipping build of my game and the first time I launch it, it is fine, but when i quit and launch the second time, the game crahes. I even tried relaunching after deleting the saved fole in AppData/Local/Project

When i open the editor, i keep getting this subtle crash in the log. Have tried many methods and nothing seems to be fix it. Not sure if this is related, but this is the only error i have in my output log in the editor and as the shipping build does not provide any logs, cannot know for sure.

development build works excellent and never has a crashing issue.

LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: ShaderType::ShouldPrecachePermutation(FGlobalShaderPermutationParameters(ShaderType::GetStaticType().GetFName(), Platform, PermutationId)) != EShaderPermutationPrecacheRequest::NotUsed [File:D:\build++UE5\Sync\Engine\Source\Runtime\RenderCore\Public\GlobalShader.h] [Line: 240]
LogOutputDevice: Error: Using a global shader permutation of FTSRRejectShadingCS which hasn’t been requested for precaching at runtime. Check the implementation of ShouldPrecachePermutation on the global shader and make sure all required or development only permutations are requested for PSO precaching
LogOutputDevice: Error: Stack:
LogOutputDevice: Error: [Callstack] 0x00007fffa8cd8186 UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffa83d84cb UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffa82966cf UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffa78a1734 UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffa8676496 UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffa862d4fa UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffe384c2f5 UnrealEditor-RenderCore.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffe3879fff UnrealEditor-RenderCore.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffe4732722 UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffe4727d4a UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffe47281ee UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffe38a894c UnrealEditor-RenderCore.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffe38ad9e4 UnrealEditor-RenderCore.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffe4d5c0ad UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007fffe4d535cf UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ff87367e8d7 KERNEL32.DLL!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ff87564c53c ntdll.dll!UnknownFunction

I have went through the forums and tried many fixes and nothing seems to resolve it.

i even setup PSO and that didnt help.

Fixes i have tried

You could try enforcing a global shader cache recompile via the command:

r.InvalidateCachedShaders

once at the games start (probably need to save if method was triggered in ini file or a savegame parameter)

Hey @3dRaven Thank you for your reply.

i tried the following, with the same crash issue and the same crash log in editor.

  1. Added it to Engine.ini
    [/Script/Engine.Engine]
    r.InvalidateCachedShaders=1

and the editor crashed on launch and got this error
Fatal error: [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\HAL\ConsoleManager.cpp] [Line: 2952] Console object named ‘r.InvalidateCachedShaders’ can’t be replaced with the new one of different type!

  1. Added it to Engine.ini as
    [/Script/Engine.Engine]
    +ExecCmds=r.InvalidateCachedShaders
    editor launched with the error log as usual and built a shipping build and used target line command and the shipping buuild still crashed.
    project.exe -ExecCmds=“r.InvalidateCachedShaders”

For my current version 5.4.4, i have downloded sentry and will try to see if it will out any real evidence.

if not, i have built a source engine for 5.7.1 and will move the project to the latest version, as a last resort, and enable a shipping log for the shipping build.

will let you know of the results.

let me know if there is something else i can try, before i upgrade the project to 5.7.1

I figured out the issue and the fix for it. For anyone who may experience this in the future. Here is the issue

  1. The PSO, Nanite and Anti-Aliasing were all puting a huge strain on the GPU on load. which is my my shipping build was crashing.
  2. As for the error log in editor, is also the reason the shipping build was crashing
    LogOutputDevice: Error: Ensure condition failed: ShaderType::ShouldPrecachePermutation(FGlobalShaderPermutationParameters(ShaderType::GetStaticType().GetFName(), Platform, PermutationId)) != EShaderPermutationPrecacheRequest::NotUsed

how did i figure this out?

  1. In your project settings>packaging> Include Debug Files in Shipping Builds - enable this.
  2. I used Sentry (sentry.io) to start decoding these error codes.
  3. Built a developer build and created a shortcut for the .exe file and then in the shortcut’s properties, find the “Target:” at the end, after “.exe” add in the following, with no quotes
    ”-dx12 -gpucrashdebugging -d3ddebug -log”
  4. Run the game and the logs will reveal the issue with your GPU crashing when PSO, Nanite and Antialiasing are competing - I used sentry to debug the errors which was provided by the log.

The fix
Go to your DefaultEngine.Ini

  1. Under the [/Script/Engine.RendererSettings], Add
    r.Nanite.Streaming.AsyncCompute=1
    This tells Unreal to stream Nanite geometry on a separate GPU lane instead of blocking rendering.

r.AntiAliasingMethod=2
this sets the AA to TAA, which will eliminate the “EShaderPermutationPrecacheRequest::NotUsed” error

r.TemporalAA.Upsampling=0
r.ScreenPercentage=100
r.TextureStreaming=true
r.Streaming.PoolSize=1000
I am enabling the Texture streaming and set it to a moderate 1gb of VRAM. modern GPUs comes with 6gb or more, so 1gb is a good start to process textures

Not sure if the following helped, but is a safe use
r.TemporalAA.HistoryScreenPercentage=100
r.TSR.History.ScreenPercentage=100
r.TemporalAACurrentFrameWeight=0.2
r.TemporalAASamples=4
r.DefaultFeature.MotionBlur=False

then i created a array with the following

[SystemSettings]
r.TSR.AsyncCompute=0
r.TSR.RejectShading=1
r.TSR.ShadingRejection.Flickering=0
r.TSR.ShadingRejection.Antialiasing=0

r.D3D12.GPUTimeout=1
r.D3D12.PSO.DiskCache=1
r.D3D12.PSO.DriverOptimizedDiskCache=1
r.D3D12.AsyncPipelineCompile=1

r.ShaderPipelineCache.Enabled=1
r.ShaderPipelineCache.SaveUserCache=1
r.ShaderPipelineCache.LoadUserCache=1
r.ShaderPipelineCache.StartupMode=3

r.PSOPrecache.Enable=1
r.PSOPrecache.Validation=0

[DevOptions.Shaders]
NeedsShaderStableKeys=true

again, i only had this issue in while using DX12 and TSR. DX11 launched the game with no issues, but DX11 with TAA has some serious ghosting issue, which I was not a fan of and refused to ship a game, which has that issue.

another line to check is the following, if you are using DX12

[/Script/WindowsTargetPlatform.WindowsTargetSettings]
DefaultGraphicsRHI=DefaultGraphicsRHI_DX12
-D3D12TargetedShaderFormats=PCD3D_SM5
+D3D12TargetedShaderFormats=PCD3D_SM5
+D3D12TargetedShaderFormats=PCD3D_SM6
-D3D11TargetedShaderFormats=PCD3D_SM5
+D3D11TargetedShaderFormats=PCD3D_SM5

hopefully this helps you out!