I spent a long time looking into this, and I just opened a PR to UnrealEngine with a patch that fixes this issue on my end: https://github.com/EpicGames/UnrealEngine/pull/11316 - we’ll see if Epic takes a look! I’ll need some help from them to determine if this is an acceptable solution.
In short, it appears that this bug occurs on the DX12 side when one thread is trying to create the swap chain, and thread is trying to destroy a window’s back buffer. I’m honestly not certain of the root cause though, as these are dark magicks I do not meddle with often.
For me, I was only able to replicate this consistently when creating a new GameMode blueprint, but it occured every time. As many of you identified, the bug appears when creating a new window and can be circumvented by simply configuring your editor to open in a new tab instead. But because this occurs in the DX12 world, another workaround is to change your project’s config to not use DX12 in Project Settings → Platform → Windows → Default RHI.
During a freeze, I saw in my debugger one thread was already frozen on a mutex that was added to the back buffer destruction, so I knew at the very least another thread was attempting this. There was some nearby code to this swap chain creation that already claimed that window association cannot happen when the back buffer is freed - and my theory was that swap chain creation cannot happen for a similar reason. You have to pass a window reference after all, so I figured it could do a similar operation under the hood. So, I basically threw in another mutex when we create the swap chain - and it worked!
As for the underlying cause for why these two things cannot occur, it appears in the original commit that introduced this mutex that it could be a bug in the DX12 DGGI, which would require a fix from Microsoft. Until then, this is working for me, but I’d understand if there is a larger scale fix that Epic may prefer instead.
Anyway, hope someone found this helpful or interesting! I’ll send an email to someone on the Epic side who works on DX12 and hopefully they can look into a hotfix for this - it really is an annoying bug.