WhatsApp Web is keeping my Mac awake

The new WhatsApp Web client is a welcome companion to the hugely popular WhatsApp Messenger cross-platform mobile application. It allows users to link their browser to their WhatsApp account and interact with chat sessions just like you do in the mobile app.

So far so good, but I have encountered one significant drawback. If you run the web client in a Google Chrome session on Mac OS X then a kernel assertion is established which prevents the system from sleeping, regardless of energy saver system preferences.

With the WhatsApp Web client running:

$ /usr/bin/pmset -g assertions
2015-01-29 17:47:11 +0000 
Assertion status system-wide:
 BackgroundTask 0
 ApplePushServiceTask 0
 UserIsActive 0
 PreventUserIdleDisplaySleep 0
 PreventSystemSleep 0
 ExternalMedia 0
 PreventUserIdleSystemSleep 1
 NetworkClientActive 0
Listed by owning process:
 pid 346(coreaudiod): [0x0006336d00011046] 00:00:50 PreventUserIdleSystemSleep named: "com.apple.audio.context532.preventuseridlesleep" 
 Created for PID: 12006.

With the WhatsApp Web session closed:

$ /usr/bin/pmset -g assertions
2015-01-29 17:47:23 +0000 
Assertion status system-wide:
 BackgroundTask 0
 ApplePushServiceTask 0
 UserIsActive 0
 PreventUserIdleDisplaySleep 0
 PreventSystemSleep 0
 ExternalMedia 0
 PreventUserIdleSystemSleep 0
 NetworkClientActive 0

I assume that this sleep issue is related to the notification feature of WhatsApp Web, since the assertion references Mac OS X’s coreaudiod process. Turning off desktop alerts and sounds in the client settings does not fix it however, so for the moment it doesn’t seem possible to prevent this system insomnia from occurring.

I shall contact WhatsApp product support and see what they can do.

Advertisements

Mac nap

Macs are generally good at honouring power saving controls, but occasionally your Mac will either not sleep automatically or wake for no apparent reason.

If your Mac won’t sleep then open a Terminal window and use this command:

/usr/bin/pmset -g assertions

This should give you output similar to the following:


Assertion status system-wide:
   PreventUserIdleDisplaySleep 0
   CPUBoundAssertion 0
   DisableInflow 0
   ChargeInhibit 0
   PreventSystemSleep 0
   PreventUserIdleSystemSleep 0
   ExternalMedia 0
   DisableLowPowerBatteryWarnings 0
   EnableIdleSleep 1
   NoRealPowerSources_debug 0
   UserIsActive 0
   ApplePushServiceTask 0

What you are looking for is the PreventUserIdleSystemSleep line, which should be set to zero. If it’s not then the process which is prevent the idle sleep should be listed, like in the example below:

Assertion status system-wide:
   PreventUserIdleDisplaySleep 0
   CPUBoundAssertion 0
   DisableInflow 0
   ChargeInhibit 0
   PreventSystemSleep 0
   PreventUserIdleSystemSleep 1
   ExternalMedia 0
   DisableLowPowerBatteryWarnings 0
   EnableIdleSleep 1
   NoRealPowerSources_debug 0
   UserIsActive 0
   ApplePushServiceTask 0

Listed by owning process:
  pid 194: [0x000000c2012c0368] PreventUserIdleSystemSleep named: "com.apple.audio.'AppleHDAEngineOutput:1B,0,1,2:0'.noidlesleep"

To check which process this is:

ps u -p <pid>

If your Mac is waking unexpectedly, check the system log for what woke your Mac from its slumber:

/usr/bin/syslog | grep -i "Wake reason"

This will return a number syslog entries which give a clue as to the reason for the wake.


Jul 29 08:49:42 mac kernel[0] <Debug>: Wake reason: EC.PowerButton PWRB (User)
Jul 29 08:50:10 mac kernel[0] <Debug>: Wake reason: EHC2
Jul 29 08:52:28 mac kernel[0] <Debug>: Wake reason: EHC1
Jul 29 08:54:13 mac kernel[0] <Debug>: Wake reason: ?

In the examples above the wake reasons were:

EC.PowerButton PWRB (User): The power button being pressed
EHC2: Wireless keyboard key press or mouse movement
EHC1: Connecting an iPad using the USB cable
?: Wake-on-Lan magic packet

Some of the wake reason codes you might encounter:

  • EHC/OHC/USB: A USB or Firewire input device such as a keyboard or mouse
  • LID0: The lid of your MacBook or MacBook Pro being opened
  • PWRB: The power button being pressed
  • RTC: Real Time Clock scheduled wake event (check for a wake schedule in System Preferences > Energy Saver > Schedule)

If there is nothing obvious in the system log then you can try finding the culprit through a process of elimination. Try each of these settings in turn and see if that makes a difference.

The first setting to check is in the Energy Saver settings in System Preferences.

Check that ‘Wake for network access’ is not checked. This prevents Wake-on-LAN ‘magic’ packets from waking your machine.

Next click on ‘Schedule’ (bottom right) and make sure there isn’t an automatic wake schedule set.

Finally if you use Bluetooth connected peripherals go into System Preferences > Bluetooth > Advanced and uncheck ‘Allow Bluetooth devices to wake this computer’.

Some applications are also known to be incompatible with Mac OS X’s sleep routines.

This is the list of apps I’ve had problems with:

  • Dropbox – disable LAN sync in Preferences
  • Drobo Dashboard (DDAssist / DDServiced / DDService64d) – uninstall completely
  • Google Drive – just quit the app, no need to uninstall
  • smcFanControl – uninstall

Good luck and happy Mac napping.