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?