17

I have my MacBook set to go to sleep after 2 minutes while on battery (via the Energy Saver preference pane.) However, when I leave it idle, it only turns off the screen—it does not actually sleep. This means that if I leave it and forget to close the lid, it always ends up with a dead battery.

The system sleeps correctly if it is triggered manually ( – Sleep) or by closing the lid. I have tested it with no USB devices connected and on a fresh user account, on the chance a background program was preventing sleep. There is no relevant information printed to the Console at the time when the system should sleep.

I've performed a PRAM and SMC reset to no avail, as well as the usual superstitious Verify Disk Permissions.

Is there anything else I should try before I reinstall OS X?

This is a MacBookPro5,5 running OS 10.6.6.

It's worth noting that I suffered from this issue some time ago due to a bug in a helper daemon for the product Things, but that this issue was slightly different and involved display sleep. Also, I have verified that the helper daemon was not running during my tests.

Additional information:

I started working through the Apple document titled "Why your Mac might not sleep or stay in sleep mode." I discovered that this issue does not appear when I Safe Boot my computer. I diff'd the process lists and discovered that the following programs are only running when in normal boot, and are thus possible culprits:

  • Quick Look Helper
  • cvmsComp_x86_64
  • kextcache
  • launchd
  • mdworker
  • mdworker
  • nmblookup
  • vmnet-bridge
  • vmnet-dhcpd
  • vmnet-dhcpd
  • vmnet-natd
  • vmnet-netifup
  • vmnet-netifup
  • Make sure you're setting Computer Sleep and not Display sleep. Photo here: http://imgur.com/yVGb4.png – Nathan Greenstein Jan 22 '11 at 17:48
  • I checked to be sure: http://cl.ly/3G110K2b443Q3R3h0t37 – Phil Calvin Jan 22 '11 at 17:54
  • 1
    Out of curiosity, can you try setting Display Sleep to something after the Computer Sleep? Maybe we'll find a bug. The other thing that comes to mind: Maybe your screensaver is activating and keeping something from sleeping (this would also be a bug). Try changing settings until it goes smoothly, Screen Saver, Display Sleep, Computer Sleep, with at least a minute between each. – Nathan Greenstein Jan 22 '11 at 18:10
  • 1
    The preference pane prevents you from setting Display Sleep to after Computer Sleep. I did try them as both the same thing and different (thinking the former might have a bug.) I also just tried Screen Saver, Display Sleep, and Computer Sleep with a minute between them, but no dice. – Phil Calvin Jan 22 '11 at 18:29
  • My guess would have been an app, but none of those processes should be preventing it from sleeping. – Harv Jan 23 '11 at 03:48
  • Looks like you've installed vmware. Did you try to disable/uninstall vmware? – Ortwin Gentz Jan 23 '11 at 12:40
  • @Phil Calvin: I have the same problem as you do. I tried narrow it down with sudo fs_usage -f filesys (http://apple.stackexchange.com/questions/6984/what-process-is-accessing-the-hard-drive), but couldn't make any sense of it. It seems random to me. Maybe you have better luck? – Martin Wickman Jan 26 '11 at 15:53
  • Have you checked the system.log with the Console app? Leave it for long enough that it should have gone to sleep, then check the log. There may be a hint there. – Jeff Snider Jan 29 '11 at 02:47
  • @Martin Wickman: Do you have any of the following programs installed? Things, VMware Fusion, Caffeine (running or not), LaunchBar? – Phil Calvin Jan 29 '11 at 03:25
  • @Jeff Snider: I just did and did not see anything enlightening. I've seen "such and such prevented a system sleep" or "waking as scheduled for program," but not here. – Phil Calvin Jan 29 '11 at 03:26
  • @Phil Calvin: Nope, none of them. I'll check the logs more carefully. – Martin Wickman Jan 29 '11 at 10:08
  • @Phil Calvin: If we assume there is an app blocking sleep, wouldn't it be possible to debug this by setting a breakpoint on kIOMessageCanSystemSleep or something like that? Ie the message OS X sends to each app checking if they can be put to sleep? – Martin Wickman Jan 29 '11 at 10:10
  • @Martin Wickman: According to this article (http://hintsforums.macworld.com/showpost.php?p=60669&postcount=18), disk activity at least once a minute (which I'm definitely seeing) is enough to prevent sleep. If I wait for a chance calm minute, it sleeps fine. For me, launchd and mdworker are the culprits, but I don't understand why they're so active compared to other installations. – Phil Calvin Jan 29 '11 at 15:52
  • @Phil: I can honestly say I have no clue anymore what's causing it. That article is from 2003 so who knows if it still apples. I think the kIOMessageCanSystemSleep should be the way to go for the system rather than keeping timers on disk accesses. Lots of programs needs disk access regularly (mail, twitter, adium etc). So if that was true, no-one should be able to sleep their Macs. Btw, I have mdworker and launchd more or less constantly producing output with fs_usage. – Martin Wickman Jan 30 '11 at 17:13
  • Great question! – conorgriffin Jan 31 '11 at 20:39
  • @Martin Wickman: I am convinced. Do you have a link to good instructions for setting such a breakpoint? I am reasonably good with Xcode's tools, but I've never used them against the operating system itself. – Phil Calvin Feb 01 '11 at 22:56
  • 1
    @Martin Wickman: I may have solved this. I had less than 5% free space on my System volume, which was being logged to the system log (but not in a way that made it clear there was a relationship.) Freeing up 50GB solved the issue. Are you also low on free space? – Phil Calvin Feb 02 '11 at 15:52
  • @Phil Calvin: Great if it solved it for you! But I have load of disk space left and get no warnings about that in the logs. I'm seriously considering the PleaseSleep utility by now. – Martin Wickman Feb 02 '11 at 20:41
  • 1
    I just found out about pmset -g assertions which shows some info about what process (or something) is preventing sleep. Check it out. – Martin Wickman Oct 15 '11 at 20:18

4 Answers4

6

To help debug sleeping issues, try the pmset command in the terminal:

$ pmset -g assertions

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

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

In this case, it's the process 2520 messing up. Check it out in activity monitor and kill it (/usr/sbin/coreaudiod started by iTunes).

After that, run the command again:

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

No flags for PreventUserIdleSystemSleep.

4

I’ve had this same issue with my MacBook Pro 3,1. It’s extremely frustrating. I went so far as to completely reinstall OS X, which didn’t solve the issue. This leads me to believe that it’s likely a hardware issue in my case.

I’ve given up troubleshooting the issue and just use PleaseSleep.

PleaseSleep is a utility software designed for Mac OS X that helps put your computer to sleep when you know some other app is preventing your Mac from going to sleep.

PleaseSleep sits in the background and waits for the sleep timer you set in Energy Saver preferences pane. Depending on the preferences you set, PleaseSleep will try to put your computer to sleep when the scheduled sleep timer kicks in. PleaseSleep is very easy to configure, you can enable, disable, and access its preferences via the system menu bar icon. You can choose to have PleaseSleep activate the sleep function all the time, or you can tell PleaseSleep to activate the sleep function only when certain apps are running.

Graham
  • 2,767
  • This is scary! If I am unable to find a "true" solution, I will most certainly try this product and accept your answer.

    However, I am stubborn and not willing to give up just yet. =)

    – Phil Calvin Feb 01 '11 at 22:59
  • Doesn't work on 10.8 – sorin Mar 25 '12 at 14:17
3

I finally have my system reliably idle-sleeping again. I changed three things to reach this point, all of which I believe were contributors:

  • I was low on disk space (less than 5% free) on my primary volume. The kernel was complaining about this to system.log (viewable in Console.app) about the time it should have been sleeping.

  • I disabled Dropbox, which accesses the disk frequently and obnoxiously, and is reported to prevent sleep in Snow Leopard.

  • I upgraded from an embarrassingly old Chromium nightly, and I'm now on 11.0.658.0 (73560). There are several bugs open about this Chrome/Chromium preventing idle sleep. However, I discovered this only after getting the system to idle sleep after a reboot with no programs running.

Technical observations follow:

It's worth noting that the Energy Saver preference pane lies a little bit. I have it set to sleep and turn off the screen after 1 minute, but the system doesn't actually go to sleep for 3 minutes and 30 seconds, give or take a few seconds to write the Safe Sleep image. The screen actually takes 2 minutes to go to sleep. I suspect this is a case of Apple knowing better than us—1 minute is probably just too fast. Regardless, this makes debugging issues like this hard because you have to wait longer than indicated to see if the system is really going to sleep.

That these two applications were contributors despite not doing anything particularly intensive suggests that Snow Leopard changed something about how the system decides whether idle sleep can occur. There is a documented API for disabling idle sleep, but it also appears that disk activity (specifically writes) more than once a minute also resets the sleep timer and thus delays sleep. Any application that writes frequently is thus a possible cause. sudo fs_usage -e grep -f filesys | grep -e write in a Terminal window can help reveal culprits.

  • 1
    The command usage here should probably be: sudo fs_usage -e grep -f filesys | grep write Without -e, it'll just vomit up the grep writes. Not helpful. – Dominic Hopton Nov 25 '11 at 18:09
  • Interesting! No vomiting occurred when I was testing this on Snow Leopard, but it does on Lion. Fixed. – Phil Calvin Dec 10 '11 at 05:43
  • There's a fairly long thread over on the Apple discussion forums that suggests Lion introduces some new possible sleep issues relating to printers and network shares. More things to try if you are, like I was, at wits' end. – Phil Calvin Dec 10 '11 at 05:55
0

Might be Spotlight indexing. You could test this by going to System Preferences > Spotlight > Search Results and unchecking everything. Then see if your MacBook goes to sleep.

conorgriffin
  • 16,501
  • 8
  • 46
  • 65