This story is also available on Medium.
I use Unity sometimes on my MacBook. It's fine except one thing. It'll keep your Mac awake once you've hit "Play" button. Mac will turn off Display when idle. But won't fully sleep until you quit Unity.
Unity allocates audio session to play sounds. It's a usual thing. But the problem is, it won't release the audio session after you've stoped the game playing.
$ pmset -g assertion
...
pid 211(coreaudiod): [0x0000aef100019a93] 00:00:03 PreventUserIdleSystemSleep named: "com.apple.audio.AppleUSBAudioEngine:Generic:USB Audio:140000:2.context.preventuseridlesleep"
You'll find a config named "Enable Output Suspension" in Audio section of Project Settings. It should help to sleep from what it says in the description. But it's not working.
This confused me. 🤔 But I figured out.
Surprisingly, there were no config key for this toggle on your project files before you've changed.
You'll see "m_EnableOutputSuspension" is created like below.
--- a/ProjectSettings/AudioManager.asset
+++ b/ProjectSettings/AudioManager.asset
@@ -12,6 +12,7 @@ AudioManager:
m_DSPBufferSize: 1024
m_VirtualVoiceCount: 512
m_RealVoiceCount: 32
+ m_EnableOutputSuspension: 1
m_SpatializerPlugin:
m_AmbisonicDecoderPlugin:
m_DisableAudio: 0
And your Mac will sleep after doing this. I also found that Unity releases the audio session after a while since you've stopped the playing.
I think this may be some sort of bugs on Unity.
Top comments (0)