Black screen when starting a packaged game

Hi, we have a strange problem where if we package the game in either Development or Shipping and launch the exe we get an infinite black screen. However, if we kill the process and launch again then the game loads perfectly fine until the system is rebooted and the same happens again.

Break-all during the hang breaks in TextBlock.cpp when it tries to find the default font:

if (!IsRunningDedicatedServer())
	{
		static ConstructorHelpers::FObjectFinder<UFont> RobotoFontObj(*UWidget::GetDefaultFontName());
...

Inside constructor helpers it ends up in a C++ library function called _init_thread_wait where it hangs. A few people who’ve come across this when using static functions with threading involved, none related to unreal however. But the suggestion of adding the compiler flag /Zc:threadSafeInit- seems to fix the black screen issue. This worked on my PC but my build machine failed to compile because the UnrealHeaderTool launches a bunch of tasks in parallel where the tasks access a StaticClass() method and sometimes returns a default value of none instead of the one which is meant to be initialised. It seems like this flag isn’t a good idea as it can effect other things, I’ve looked at only adding this flag during packaged builds but haven’t yet found a way to do this in VCToolChain.cs, however, this is more of a workaround anyway.

Lastly, the commit which caused this black screen issue in the first place was a change to a widget. The furthest I managed to narrow this down was to a reference from a Widget → Data Asset → Blueprint. If I remove the reference in the data asset then I don’t get the black screen issue. A while ago I got the same black screen issue, and the fix was changing a texture’s compression setting from UserInterface2D to Default.

If anyone has any ideas it would be greatly appreciated!

Hello!

Were you able to resolve this issue? I encountered an error that might be related to this. When I run the code you have above on a UE 5.1.1 dedicated server, I get this error:

LogStreaming: Warning: LoadPackage: SkipPackage: /Engine/EngineFonts/Roboto (0x6DC6E590848F5708) - The package to load does not exist on disk or in the loader
LogUObjectGlobals: Warning: Failed to find object 'Font /Engine/EngineFonts/Roboto.Roboto'