Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Significant CPU usage increase when playing in fullscreen mode with Vsync enabled #65649

Open
Marigem opened this issue Sep 11, 2022 · 5 comments

Comments

@Marigem
Copy link

Marigem commented Sep 11, 2022

Godot version

Godot Engine v3.5.stable.official.991bb6ac7

System information

Windows 10, i7-7700k, GTX 1050TI

Issue description

CPU usage increases in any project when fullscreen is on and Vsync is enabled. I also experience occasional hitching in the games in fullscreen mode which may be caused by this.

I don't have this problem with other games, engines or programs.

image

Steps to reproduce

N/A

Minimal reproduction project

No response

@lawnjelly
Copy link
Member

A couple of questions:

  • What are the window sizes with fullscreen off and fullscreen on?
  • And what is the frames per second with vsync off and on (in full screen)?

If possible provide a minimum reproduction project that exhibits this, otherwise there is very little we have to go on.

@Calinou
Copy link
Member

Calinou commented Sep 11, 2022

I'd recommend looking into using a C++ profiler on a debug build to determine where the increased CPU usage comes from. (You'll have to run two profiles, one at the default window size and one in fullscreen.)

@Marigem
Copy link
Author

Marigem commented Sep 11, 2022

Window size with fullscreen off is "maximised" on a 1920x1080 monitor. So it's close to full resolution, resizing it and making it smaller doesn't make a difference. Fullscreen on is 1920x1080. This happens on every project (even the tutorial ones), so properties like display/window/size/width and display/window/size/height don't make a difference.

Frames per second is 144 on a 144hz monitor, in fullscreen on and off (with vsync).
force fps is set to 200 (also tried 300 and 400), so when vsync is disabled, the fps can be much higher, without the CPU usage increase.

I noticed in a similar issue, #21586, that the CPUs are the same, so maybe that could have something to do with it. Now that i'm looking at it again, this issue maybe is a duplicate of that one.

I will try profiling with visual studio and a debug build and post the resulting file when I get the chance.

@lawnjelly
Copy link
Member

lawnjelly commented Sep 12, 2022

This is why an MRP is important, it allows us to see what you have changed from defaults. In this case interesting is the force_fps. If you look at the documentation for force_fps it says this:

Maximum number of frames per second allowed. The actual number of frames per second may still be below this value if the game is lagging. See also physics/common/physics_fps.
If display/window/vsync/use_vsync is enabled, it takes precedence and the forced FPS number cannot exceed the monitor's refresh rate.
This setting is therefore mostly relevant for lowering the maximum FPS below VSync, e.g. to perform non-real-time rendering of static frames, or test the project under lag conditions.
Note: This property is only read when the project starts. To change the rendering FPS cap at runtime, set Engine.target_fps instead.

The help file should probably be clearer, this should not imo be used in most games, as it can completely mess up timing as it uses sleep(). In most games you never want to touch this (outside of menus) unless you are e.g. on mobile and trying to limit CPU. It is more likely to be useful for debugging.

Try setting this back to the default 0, and see your results then. Currently the force_fps will be overriding the normal behaviour and giving all kinds of strange results.

Also CPU use can change depending on the method your OS uses for vsync in windowed and fullscreen, so it is possible the CPU might be outside of Godot. There are also various OS window compositing systems that may work differently in windowed and fullscreen, so there's a huge amount of variation that can occur here totally outside of Godot.

@Marigem
Copy link
Author

Marigem commented Sep 12, 2022

In some projects force fps is untouched, and it still happens. I also created a brand new project and only added toggling fullscreen with f11, and it still happens.
I used VerySleepy on a debug build for profiling since it was recommended, below are the results.

fs-mrp.zip - Run project and press f11 to toggle fullscreen
fullscreen-off-capture.csv - exported as csv
fullscreen-off-capture.txt - change extention to .sleepy
fullscreen-on-capture.csv - exported as csv
fullscreen-on-capture.txt - change extention to .sleepy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants