-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Godot seems to cause coreaudiod to use excessive CPU time. #38154
Comments
On my 2013 Mac Pro, macOS 10.15.4 (19E287), Godot cause some constant (about 1.2%) Audio I/O processing is started on driver init and is always running. You can disable audio completely by setting audio driver to "Dummy" ( |
The editor uses audio when you play back AudioStreamPlayers to preview them 🙂 Still, I agree we should make the project manager use the Dummy audio driver. |
Also, it might be helpful to make it easier to disable audio... It's not obvious in the project settings, a simple check box would be nice. |
@h5n1xp Due to how audio driver swapping is implemented, I don't think it'd make sense to add a separate checkbox to disable audio. There would be two ways to accomplish the same thing, each with their own implementation. |
I have the same problem (Godot 3.2.2, macOS Catalina, version 10.15.6). Why is Godot loading coreaudiod so much when no sound is playing / no audio player is active? It causes the computer to heat up unnecessarily. P.S. I never noticed the same issue on my previous MacBook running macOS 10.14. |
@ArdaE Can you try using a profiler? Either way, you can start the editor with the |
With the current audio driver implementation, Godot is constantly outputting audio as long as driver is loaded, it's just 0-level if there's no audio stream is active. Probably we should not start output callback loop if there is no active streams, like it's done with the audio capture. Output callback loop is activated in driver init: godot/servers/audio_server.cpp Line 944 in aada93a
instead of stream start: godot/servers/audio/audio_stream.h Line 43 in aada93a
Input callback loop is started in the stream start, and stopped when stream is stopped: godot/servers/audio/audio_stream.cpp Line 194 in aada93a
|
Profiler won't help much, on the Godot side audio stream usage is |
Thanks for the info @Calinou.
Most of the CPU activity reported by |
For anyone who wants to use the |
I think this is the solution to fixing the bug! Audio is a relatively demanding task, no need to start the output if there are no active streams! Well done @bruvzg 👍🏻 |
Assuming audio would be turned off when the last active audio stream ends playing, which would be ideal, it might be worthwhile to add optional manual control over this in consideration for apps that play audio streams intermittently without any ongoing background audio. This would be especially important when Bluetooth devices are involved, as they tend do turn on and off as needed, and can have a significant delay whenever audio starts getting streamed after some inactive period. Further, operating systems like macOS and iOS enable audio in a smooth way, which ends up cutting off the beginning of sounds if an audio session is not already active at the time audio starts getting streamed. Therefore it would be ideal for games/apps to be able to activate the audio session when they know sounds will follow soon, and to be able to shut down the audio session when they know they won't need the audio system for awhile. The manual control shouldn't be the default, as it would add unnecessary complexity for the average user, but should be there for proper control over the sound system for the best user experience. |
Would it be reasonable to stop the coreaudio playback stream in the editor only after 15 seconds of inactivity by default? Restarting the playback stream seems like it takes a few milliseconds so I would strongly oppose shutting the stream off without waiting a bit. But I really don't think there's an argument to be made that this is a problem after 15 seconds, at least in the editor. The next question is would it be okay to do the same in an exported game? I don't have strong feelings one way or the other here, but I think it may be worth considering as a configurable option. I care more about #28039 than this issue but I believe the fix for #28039 will mitigate this issue as well, and @Calinou suggested that they may in fact be the same problem (I have not confirmed this though). If this seems like a reasonable thing to do for the editor I can send out a PR. |
If CoreAudio is active the Mac won’t sleep (because MacOS thinks the machine is playing audio), so I agree that these issues are likely related. |
I think it's a good idea to suspend CoreAudio in the editor after ~10-15 seconds of silence, but not in exported projects by default. Those who need CoreAudio suspension in exported projects should enable it with a project setting instead (as it'll be disabled by default). |
Cool, I wrote the fix against the 3.2 branch because that's what I use, but I'll rebase to master after work and create the PR. |
Is there some way to set It's a shame to see 6-10% of my CPU get used for nothing when I don't have sounds in some projects. Edit: Nvm found it: Project Settings -> Audio -> Driver -> "Dummy" |
Godot version:
3.2.2
OS/device including version:
macOS Catalina (10.15.4), 2020 MacBook Air i7 16gb RAM.
Issue description:
Godot seems to cause coreaudiod to use excessive CPU time. This happens even in the project manager and editor which don't need to be using Audio. This is an issues as it causes Godot based software to burn more battery than they need to.
Steps to reproduce:
Just start Godot editor and look at the activity monitor, the coreaudiod CPU usage will jump from 0% to ~10%
Minimal reproduction project:
N/A
The text was updated successfully, but these errors were encountered: