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

Heavier CPU/GPU load when in a different space on macOS #1638

Open
molevision opened this issue Oct 14, 2020 · 4 comments
Open

Heavier CPU/GPU load when in a different space on macOS #1638

molevision opened this issue Oct 14, 2020 · 4 comments
Labels

Comments

@molevision
Copy link

@molevision molevision commented Oct 14, 2020

There's a strange one here.

When a love2d window is in a different space on macOS, so on another desktop, or if you have it running on your desktop and switch to a full screened app, CPU and GPU load are doubled (or tripled). This is could be up to 30-40% CPU from under 6% otherwise, on a quad core machine and 100% GPU up from 30% on a discrete AMD card: all with no game loaded.

The CPU issue was also replicated on any game I tested, where if a game is in the same space (with or without focus) CPU usage on my machine is always under 10%, but on a different space (without focus, obviously), it climbs up to 40 or 50%, every time. The GPU doubling issue is present on every game run with hiDPI.

This was tested on a 2015 and 2019 MBP with discrete graphics, on Mojave and Catalina both.

To test:
Open Activity Monitor, select Window > CPU History and GPU History. Then open any love2d game with hiDPI or just the no game app. See the the normal load on the monitors. Then open Mission Control, create a new desktop, and drag the love2d window into Desktop 2. Now come back to Desktop 1, and see the change in load.

@molevision molevision changed the title Heavier CPU/GPU load when not in focus on macOS Heavier CPU/GPU load when in a different space on macOs Oct 14, 2020
@molevision molevision changed the title Heavier CPU/GPU load when in a different space on macOs Heavier CPU/GPU load when in a different space on macOS Oct 14, 2020
@slime73
Copy link
Member

@slime73 slime73 commented Oct 14, 2020

From what I remember, the OS doesn't enforce vsync in opengl windows that aren't in focus.

@molevision
Copy link
Author

@molevision molevision commented Oct 14, 2020

From what I remember, the OS doesn't enforce vsync in opengl windows that aren't in focus.

That's crazy that that's default behaviour. Is there any way around this?

@slime73
Copy link
Member

@slime73 slime73 commented Oct 15, 2020

Is there any way around this?

As a developer you can't rely on a specific vsync rate regardless (because graphics drivers tend to give users the option to force vsync on or off, and because monitors use all sorts of different refresh rates - I have a 60hz and a 120hz monitor connected to my PC).

A typical approach to lowering CPU/GPU load while a game isn't in focus is to use love.timer.sleep to pause for a few ms every frame while the window isn't in focus or isn't visible.

macOS also provides apps some extra information about window visibility (whether it's completely covered by other windows or not), but love doesn't expose that at the moment unfortunately.

@slime73 slime73 added the 11.3 label Oct 17, 2020
@molevision
Copy link
Author

@molevision molevision commented Oct 23, 2020

A typical approach to lowering CPU/GPU load while a game isn't in focus is to use love.timer.sleep to pause for a few ms every frame while the window isn't in focus or isn't visible.

I've been looking in the love forums and every one has their own way of handling this, which I've had some trouble implementing and seeing consistent results. Is there any optimal way you recommend? Does does the sleep function need to be handled within love.update or can love.run be modified instead?

macOS also provides apps some extra information about window visibility (whether it's completely covered by other windows or not), but love doesn't expose that at the moment unfortunately.

What's odd here is that it's specifically being on another space that uncaps vysync. When I'm on on the desktop but unfocused, it's all normal. Also, somehow demo-ing my game on Zoom screen sharing makes it go crazy, 100-200% CPU usage and max GPU always, even love is in focus, on the desktop or full-screened.

@love2d love2d deleted a comment from unicornaz Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.