Hi, we’ve encountered the same issue in a project I’m working on in UE 5.3.2, and luckily I’ve found a workaround for it.
So I’m sharing our solution here in case someone else still uses one of the older engine versions, to hopefully save them some time debugging.
You’ll need to use a custom engine build, and add a following code to SceneViewport.cpp, into ResizeViewport function right before the Draw()call.
// Workaround for the game hanging if full-screened / alt-tabbed
#if PLATFORM_MAC
ENQUEUE_RENDER_COMMAND(FlushPendingRHICommands)(
[](FRHICommandListImmediate& RhiCmdList)
{
RhiCmdList.BlockUntilGPUIdle();
});
#endif
Exact line of code might differ in other engine versions, so here’s a visual guide where it needs to go:
For anyone interested this will make the render thread wait until the previous frame is fully renderer. Otherwise the FMetalRHIRenderQuery::GetResult function is repeatedly called for every object and tries to get result of old occlusion queries, while it has 500ms timeout for each (thus the long hang).
I’m certain this is not the best solution, but it’s the best I could do in the limited time I’ve had for this bug. Cheers!
