[bug]packaged game stuck at launch

I packaged my project for Mac. No error or warning. But it stuck at some strange points when I ran the game. here is the log when the game stuck. However, on PC, everything work fine. So, I guess this is an engine’s bug. Please help me…

update:

After investigation, I have finally located the bug and fixed it. Below is my solution. the bug is in UnrealEngine/Engine/Source/Runtime/Core/Private/Mac/MacWindow.cpp, line 423~432, function FMacWindow::SetWindowMode. It’s an infinite do-while loop and it stuck the packaged game launch.

       do
		{
			FPlatformMisc::PumpMessages(true);
			WindowIsFullScreen = [WindowHandle windowMode] != EWindowMode::Windowed;
		} while(WindowIsFullScreen != bMakeFullscreen);

I changed the function as below.

void FMacWindow::SetWindowMode( EWindowMode::Type NewWindowMode )
{
	SCOPED_AUTORELEASE_POOL;

	// In OS X fullscreen and windowed fullscreen are the same
	bool bMakeFullscreen = NewWindowMode != EWindowMode::Windowed;
	bool bIsFullscreen = GetWindowMode() != EWindowMode::Windowed;

	if(bIsFullscreen == bMakeFullscreen && NewWindowMode != GetWindowMode())
	{
		SetWindowMode(EWindowMode::Windowed);
	}
	
	if( bIsFullscreen != bMakeFullscreen || NewWindowMode != GetWindowMode() )
	{
		bool WindowIsFullScreen = !bMakeFullscreen;
		
		NSWindowCollectionBehavior Behaviour = [WindowHandle collectionBehavior];
		if(bMakeFullscreen)
		{
			Behaviour &= ~(NSWindowCollectionBehaviorFullScreenAuxiliary);
			Behaviour |= NSWindowCollectionBehaviorFullScreenPrimary;
		}
		
		if(!bIsFullscreen)
		{
			PreFullscreenWindowRect.origin = [WindowHandle frame].origin;
			PreFullscreenWindowRect.size = [WindowHandle openGLFrame].size;
			WindowHandle.PreFullScreenRect = PreFullscreenWindowRect;
		}
		
		WindowHandle.TargetWindowMode = NewWindowMode;
		
		MainThreadCall(^{
			SCOPED_AUTORELEASE_POOL;
			[WindowHandle setCollectionBehavior: Behaviour];
			[WindowHandle toggleFullScreen:nil];
		}, UE4FullscreenEventMode, true);
		
		// Ensure that the window has transitioned BEFORE leaving this function
		// this prevents problems with failure to correctly update mouse locks
		// and OpenGL contexts due to bad event ordering.
		do
		{
			FPlatformMisc::PumpMessages(true);
			WindowIsFullScreen = [WindowHandle windowMode] != EWindowMode::Windowed;
		} while(WindowIsFullScreen != bMakeFullscreen);
	}
	else // Already in/out fullscreen but a different mode - we should just update the mode rather than forcing the window to change again
	{
		WindowHandle.TargetWindowMode = NewWindowMode;
		[WindowHandle setWindowMode:NewWindowMode];
	}
}

I copied these codes from GitHub. And the problem solved. Someone may have missed some code. Please fix this bug. My English is poor. I do not know if I described it clearly.

I do not know what caused this bug. I can not reproduce this error. But I know how to fix this error. There must be some logical error somewhere in the engine. I upgraded my project to version 4.18. This error still exists. I also found the repair method. In the file Engine/Source/Runtime/ApplicationCore/Private/Mac/MacWindow.cpp, insert the following code after line 621.

NSWindowCollectionBehavior Behaviour = [WindowHandle collectionBehavior];
Behaviour &= ~(NSWindowCollectionBehaviorFullScreenAuxiliary);
Behaviour |= NSWindowCollectionBehaviorFullScreenPrimary;
[WindowHandle setCollectionBehavior: Behaviour];