Sleepless Mac

1 minute read

Ever put your Mac to sleep only to come back find it’s still awake? This happens because something is telling the power management subsystem it can’t sleep yet. These are called “power assertions” and you can view them by running:

pmset -g assertions
2017-05-09 16:15:57 -0600
Assertion status system-wide:
   BackgroundTask                 0
   ApplePushServiceTask           0
   UserIsActive                   1
   PreventUserIdleDisplaySleep    0
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     1
   NetworkClientActive            0
Listed by owning process:
   pid 237(coreaudiod): [0x000472fb00018753] 00:09:40 PreventUserIdleSystemSleep named: "com.apple.audio.AppleHDAEngineOutput:1B,0,1,1:0.context.preventuseridlesleep"
	Created for PID: 54000.
   pid 127(hidd): [0x00045a9800098430] 01:53:42 UserIsActive named: "com.apple.iohideventsystem.queue.tickle.4295002300.3"
	Timeout will fire in 599 secs Action=TimeoutActionRelease
Kernel Assertions: 0x100=MAGICWAKE
   id=507  level=255 0x100=MAGICWAKE mod=5/9/17, 2:47 PM description=en0 owner=en0
Idle sleep preventers: IODisplayWrangler

Not all assertions prevent sleep, just PreventUserIdleSystemSleep and PreventUserIdleDisplaySleep. I turn these into a BASH alias sleepless:

alias sleepless="pmset -g assertions | egrep '(PreventUserIdleSystemSleep|PreventUserIdleDisplaySleep)'"

which gives you a nice, short list:

   PreventUserIdleDisplaySleep    0
   PreventUserIdleSystemSleep     1
   pid 237(coreaudiod): [0x0005051000018753] 00:15:51 PreventUserIdleSystemSleep named: "com.apple.audio.AppleHDAEngineOutput:1B,0,1,1:0.context.preventuseridlesleep"

There are some things, like Bluetooth advertisements:

pid 370(useractivityd): [0x0005077200019fcf] 00:00:02 PreventUserIdleSystemSleep named: "BTLEAdvertisement"

that pop up briefly and don’t actually prevent sleep. Run sleepless a few times to get a sense of what’s actually stuck.

Once you know what process that’s keeping you awake is, you have to find the actual cause. While it’s possible that it’s an app you can just quit, more often than not, it will be a system process that an app is talking to, for example coreaudiod. So, you have to quit apps one at a time until you find the culprit. If it is coreaudiod, start with tabs in your browser.

For me, it’s always a Flowdock tab in Chrome. It will be different for you, but pretty quickly you’ll know where to look and sleep will come at last.

Tags: ,

Updated:

Comments