Unreal Engine Crashing on macOS When Applying Fullscreen to a Monitor

I’m working on an Unreal Engine project, and I’m encountering an issue where my application crashes or becomes unresponsive on macOS when applying fullscreen to a specific monitor.

I have a function, ApplyFullscreenToMonitor(), that applies fullscreen mode to a selected monitor. It first retrieves the display metrics and then tries to move and resize the window based on the monitor’s resolution and position. The function works fine on Windows, but on macOS, the app freezes or becomes unresponsive.

Here’s the code:

void UEtrResolutionSetting::ApplyFullscreenToMonitor()
{
    // Get game user settings
    UGameUserSettings* GameUserSettings = GEngine->GetGameUserSettings();
    if (GameUserSettings)
    {
        FDisplayMetrics displayMetrics;
        FSlateApplication::Get().GetDisplayMetrics(displayMetrics);
        const int32 num = displayMetrics.MonitorInfo.Num();

        int32 chosenIndex = -1;
        int32 primaryIndex = 0;

        for (int32 i = 0; i < num; i++)
        {
            FMonitorInfo& info = displayMetrics.MonitorInfo[i];
            if (info.Name == SelectedMonitor.Name)
            {
                chosenIndex = i;
                break;
            }
            if (info.bIsPrimary) { primaryIndex = i; }
        }

        int32 finalIndex = (chosenIndex < 0) ? primaryIndex : chosenIndex;
        if (chosenIndex < 0 && !SelectedMonitor.Name.IsEmpty())
        {
            // NOTE: Log something here
        }

        const FMonitorInfo& info = displayMetrics.MonitorInfo[finalIndex];
        const FIntPoint resolution = GameUserSettings->GetScreenResolution();

        if (resolution.X > info.NativeWidth || resolution.Y > info.NativeHeight)
        {
            GameUserSettings->SetScreenResolution({ info.NativeWidth, info.NativeHeight });
        }
        GameUserSettings->SetWindowPosition(info.WorkArea.Left, info.WorkArea.Top);

        if (GEngine && GEngine->GameViewport && GEngine->GameViewport->GetWindow())
        {
            TSharedPtr<SWindow> window = GEngine->GameViewport->GetWindow();
            EWindowMode::Type const WindowMode = GEngine->GetGameUserSettings()->GetFullscreenMode();

            window->MoveWindowTo(GameUserSettings->GetWindowPosition());
            window->Resize(GameUserSettings->GetScreenResolution());
            window->SetWindowMode(WindowMode);

            GameUserSettings->SetFullscreenMode(WindowMode);
            GameUserSettings->ApplyResolutionSettings(false);
        }
        else
        {
            mDelegateHandleViewportCreated = UGameViewportClient::OnViewportCreated().AddUObject(
                this, &UEtrResolutionSetting::ApplyFullscreenToMonitor);
        }
        if (mDelegateHandleViewportCreated.IsValid())
        {
            UGameViewportClient::OnViewportCreated().Remove(mDelegateHandleViewportCreated);
            mDelegateHandleViewportCreated.Reset();
        }
    }
}

Greetings @AAKASHBASHYAL

I’d be happy to take a look into this issue. Do you have a crash log I can take a peek at? Thanks!

I did tried to search for the crash log, but couldn’t find it on my mac. Can you guide me where could i find them?

Take a peek here [question] Where are logs generated on Mac? [UE4-27]. They’re usually located in one of the locations they’re mentioning in that post.

I thank you for replying, It seems like when i made the development build and try it, the app doesn’t get crash, and it crash or say it get not responsive only on shipping build. And on shipping build i don’t get logs.

Seems this is the issues here.

Because I am also using version 5.2.1.

Does this happen only on the 5.2 build or is it occurring on other versions as well?

From:

K so good news: I found a solution for this using UE5.3.2, however it requires building it from source. The solution to this bug looks like you would have to apply the bug solution (this git commit) to UE5.3.2’s source code by cloning and building it from GitHub and changing the code in the MetalViewport.cpp file as indicated through the changes in these two photos below (*Note: The line numbers shown here aren’t one-to-one, so just try to compare the code to locate where to make these changes):


That said, this fix may be unattainable as I write this (Jan 2025), due to the awkwardness with building UE5 from source with Xcode 16.2, but hopefully this helps anyways.

Another solution would be to upgrade to UE5.5 through the Epic Games installer, however all things considered it seems that UE5.3.2 is the most stable release (for my project at least).

So TL;DR: unless we get a patch from Epic Games to UE5.3.2 that directly resolves this bug (i.e. UE5.3.3[?]), it looks like modifying UE5 from the source code is the best solution.

Hope this helps :sweat_smile: