Mac Fullscreen Issues

Hello!

I’ve recently noticed a bit of a strange problem on MacOS which is that my window performance drops off pretty dramatically when I enter fullscreen mode.

I’m using GLFW with Vulkan, and everything should be up to date, I just downloaded the latest versions of GLFW and the Vulkan SDK today while troubleshooting, and I’m running MacOS 14.5. My hardware is also an M1 Max 16 inch MacBook Pro model, and I’m not connected to any external displays.

I’m working on a tech demo game engine that’s rendering part of a 3D scene, and I also have a basic FPS counter implemented to track performance. The first thing I notice is that the FPS is usually throttled by Vsync and runs at a consistent 120 FPS in windowed mode. As soon as I go to fullscreen mode, though, it drops down to about 80-90 FPS and gets stuck there.

At first I thought this might be related to fullscreen using more resolution, but if I turn off Vsync by using the MacOS Quartz debug tools, the FPS performance hovers between 140-180 FPS, regardless of if it’s in windowed or fullscreen mode. So from a hardware perspective, the system should be able to output more than enough frames to keep pace with the 120 Hz refresh rate.

I’m wondering if it could be related to MacOS’s Vsync and how it interacts with the variable refresh rate in the ProMotion retina screen, so I tried setting the MacBook screen to a fixed 60 Hz resolution, and doing that I got a smooth 60 Hz in windows and fullscreen mode.

I’m not sure if this is a problem with GLFW or with MoltenVK, or something related to MacOS itself, but I thought this would be a good place to start since going fullscreen is what triggered the issue.

Thanks for your time!

John

Hi @Muketsu,

With Vulkan you handle buffer swapping directly (i.e. via MoltenVK), and GLFW is relegated to handling window events and input. So unless event processing in glfwPollEvents is taking a lot of time (you could either profile this or add a simple timer around the function call), the performance issue likely isn’t related to GLFW in this case.

So I would look at the issues on the MoltenVK repo, and perhaps file one if there is none. You might need to build a minimal viable reproduction sample.

Cheers,

Doug.

Hello,

Thanks for the reply! I did a little bit more testing this morning, and was actually able to reproduce it with the cube app demo that comes with the Vulkan SDK, so it looks like it is related to MoltenVK or MacOS, and not GLFW specifically. I don’t see any issues on the MoltenVK repo that look like they’re describing this, so I’ll probably try to submit one soon.

Thanks for your help!

John

Hey Muketsu.
Thanks for posting this.

I’m also experiencing exactly the same issues as you described. My MacBook model is exactly the same as yours and I’m running exactly the same macOS version too :slight_smile:

My App is written in Golang using GLFW 3.3 and Vulkan Wrapper (Vulkan version 1.1.211)

My App displays fly-by scene with around 2M textured triangles, I had consistent 120 FPS on fullscreen in highest 4K resolution before (on earlier macOS versions, so it has been broken on some macOS version, probably 14.5).

What I’ve found though is the following:

  • If you run the App in windowed mode, and maximize window to fullscreen, then move your mouse cursor to the top of the screen to reveal the Top Menu Bar, then for that period of time you will get 120 FPS again, but once you hide the Top Menu Bar by moving your cursor away, FPS will again drop to 80-90 FPS.

I’ve done some extra research and I’ve found that latest macOS introduced so-called “Game Mode” which bumps process priority for your app (game).

Automatically prioritises the performance of your game for smoother, more consistent frame rates and improved in-game responsiveness

Game Mode
Apple Dev Forum Answer

In order to enable that mode, you need to add the following key to your application bundle Info.plist file:

<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>

Once this is done, when I run app from within macOS bundle, and switch to fullscreen mode, I’m getting system notification in the top right corner, saying:

Game Mode: On
Game mode prioritises the performance of this game while in full

When that notification is present on screen the FPS will be 120 FPS, once it disappears it will be 80-90 FPS again.

But that doesn’t solve the problem with FPS. What does (temporarily), is when you reveal Top Bar Menu again, you will see new GamePad like icon there, you can click on it and from menu you can either turn Game Mode OFF or ON.

But when you switch it to ON, it might be still broken (currently set value doesn’t really matter).

What matters is simply Toggling that value! :slight_smile:

Once you toggle it, move cursor away, and voila you will get 120 FPS again without toolbar being visible. This is only fixing the issue temporarily, as when you restart the app you need to do same dance again.

Pretty weird ha!?

Apple has messed something up, and I’m waiting for macOS 14.6 and hoping it will fix it.

Please confirm that you can fix it temporarily in the same way.

Thanks.
Mojzesh

Forgot to mention one more thing.

My App got consistent 120 FPS after connecting external display (running at 2560x1600@60) and when app window is displayed on fullscreen on main MacBook’s display (second display just shows the desktop).
In this case, no entries to Info.plist were required, it just works as usual.

Pretty weird :slight_smile:

Mojzesh