godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.04k stars 21.18k forks source link

Godot prevents automatic sleeping due to the audio system #28039

Open robgraeber opened 5 years ago

robgraeber commented 5 years ago

Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version: 3.1

OS/device including version: Mac OSX 10.14

Issue description: The godot editor is preventing Mac's from automatically sleeping, according to the activity monitor.

Screen Shot 2019-04-14 at 7 45 14 PM

Steps to reproduce: Open any godot project.

akien-mga commented 5 years ago

Might be due to requiring the high perf GPU. This makes sense for exported games, but should maybe not be enabled by default for the editor itself.

codespren commented 5 years ago

Can confirm this bug. To prevent it you have to close godot every time when you stop using computer. Otherwise Godot will burn your battery when you think the laptop is asleep.

This is very problematic because when we talk about macbooks and other modern laptops, people may take a break (and put laptop asleep) easily 10 times a day. To use godot you should remember to close it every single time. If you don't, then when you next time try to use computer you find out that Godot has drained all the battery.

So first it might sound like a small inconvenience but for some people and use cases this is a critical, software breaking bug.

Perhaps editor setting that allows users to switch this behaviour off would solve the problem?

Calinou commented 5 years ago

@codespren Can't you still put the laptop to sleep manually in this case? This is generally what you should be doing to maximize its battery life, so it doesn't idle for a few minutes before going to sleep.

I'm afraid making Godot use integrated graphics by default isn't an option, as it will probably feel sluggish on Retina displays (even when working on a 2D game). We could have a checkbox for this in the Editor Settings, but then, it should be implemented for all platforms.

Also, which MacBook model do you have?

codespren commented 5 years ago

It's MacBook Pro, Intel Core i5, 8 Gb memory and Intel Iris 1536 MB graphics card with MacOS Mojave. So I'm actually using Godot with integrated graphic card and doing 3D-stuff and Godot runs great but I'm using only lowpoly objects and don't use any demanding graphic settings.

I can put it sleep manually by selecting sleep from menu or by closing lid and it behaves same way when Godot is running and when it is not. I only found out that Godot is not actually sleeping because first I left Godot running just like other software and later when I tried to continue working the battery was empty.

I agree that It's better to use better graphics by default. Most users probably expect that. I also did some testing and other 3D software are also preventing sleeping, tested it with Unity and Blender. I'm starting to change my mind about this. Maybe laptop users should just deal with it and close those programs manually. Or write a script that closes them automatically when the laptop goes sleep.

Dentrax commented 4 years ago

Exactly same issue with Macbook Pro, Godot quickly reduced my battary from percent 90 to 15 in 2 hours, while in sleep.

Screen Shot 2020-03-23 at 13 56 41

Battery drain became stable after closing Godot. @akien-mga

ellenhp commented 3 years ago

I'm going to look into this after work because it's bugging me. It looks like it might be the audio system preventing sleep. Perhaps the editor is always playing silent audio even if there aren't any active audio sources?

Before and after closing godot:

~/dev/godot/godot 21/02/11 09:04:42 [3.2] $ pmset -g

System-wide power settings:
Currently in use:
 powernap             1
 sleep                1 (sleep prevented by powerd, coreaudiod)
 Sleep On Power Button 1
 ttyskeepawake        1
 tcpkeepalive         1
 disksleep            10
 standby              1
 displaysleep         2
~/dev/godot/godot 21/02/11 09:05:06 [3.2] $ pmset -g

System-wide power settings:
Currently in use:
 powernap             1
 sleep                1 (sleep prevented by powerd)
 Sleep On Power Button 1
 ttyskeepawake        1
 tcpkeepalive         1
 disksleep            10
 standby              1
 displaysleep         2
Calinou commented 3 years ago

I'm going to look into this after work because it's bugging me. It looks like it might be the audio system preventing sleep. Perhaps the editor is always playing silent audio even if there aren't any active audio sources?

In this case, this issue is a duplicate of https://github.com/godotengine/godot/issues/38154. See also this workaround:

Either way, you can start the editor with the --audio-driver Dummy command-line argument if you don't need it to play sound. The running project should still be able to play sound if you do this.

ellenhp commented 3 years ago

I confirmed that it's the audio system. I have a hacky fix, and will continue discussion on #38154.

p10tr3k commented 2 years ago

Still exists on MacOs Ventura and Godot 3.5.1 Any plans for a fix in the near future?

Calinou commented 2 years ago

Any plans for a fix in the near future?

There's no ETA for resolving this issue, as contributors work on a best-effort basis. You can test https://github.com/godotengine/godot/pull/63458 locally, but it needs a rebase (and a port to 4.0's largely rewritten audio system) before it can be merged.

akien-mga commented 1 year ago

CC @bruvzg

nabil-alsabah commented 1 year ago

I'm using Godot 4 Beta 7 and the issue still hasn't been resolved...

AndreiSchapov commented 1 year ago

4.0 Beta 9, still here

xentripetal commented 1 year ago

4.0 RC2 still prevents sleep regardless of https://github.com/godotengine/godot/pull/71325

Screenshot 2023-02-14 at 11 33 12 PM
Riteo commented 1 year ago

@xentripetal #71325 has nothing to do with this issue, this happens due to the audio system staying on at all times.

rm-code commented 1 year ago

Not sure if this is a side effect of this issue (if not I can open a new issue), but yesterday I noticed that when I close my MBP with Godot still running it also doesn't really go to sleep. The worse part however is, that the fans stop working but the MBP still produces a lot of heat. When I went back to it a few hours later it was pretty hot, and when I opened it the fans kicked in immediately.

Can anybody else confirm if this is also caused by the audio system?

Calinou commented 1 year ago

Not sure if this is a side effect of this issue (if not I can open a new issue), but yesterday I noticed that when I close my MBP with Godot still running it also doesn't really go to sleep.

I could notice this with the editor on Linux too (with no project running). I wonder if https://github.com/godotengine/godot/issues/64100 is actually not fixed in 4.0.2, since there is an editor feature tag override for the Keep Screen On project setting.

Can you reproduce this if you disable Keep Screen On in the advanced Project Settings, then restart the editor?

Can anybody else confirm if this is also caused by the audio system?

Try starting the editor with the --audio-driver Dummy command line argument to check. (Note that this argument is not passed from the project manager to editor, so open a project directly in the editor via command line arguments instead.)

alexzheng commented 1 month ago

I have a question: I have used godot for years, I just noticed this issue after upgrading to Mac OS 15, it not always keep the fan running and heat the device after close the lid. Is it safe to just close the lid with the godot open? will it always drain the power?