When resuming from hibernate, weird garbage on screen

For some reason, when returning from an hibernate after i.e. battery drops to 0%, I get this:

Glitches on Mac screen

Mind that this only happens with a few programs, and reopening them works most of the time, and a full reboot fully solves the issue.

It's a Early 2011 Macbook Pro 13'' (Base model), with RAM upgraded to 8GB 1867mhz and 128GB SSD, running Lion 10.7.3.

Edit:

~ ‹›  $ pmset -g
Active Profiles:
Battery Power       -1*
AC Power        -1
Currently in use:
 standbydelay   4200
 standby    0
 halfdim    1
 sms        0
 panicrestart   157680000
 hibernatefile  /var/vm/sleepimage
 disksleep  0
 sleep      10
 hibernatemode  0
 ttyskeepawake  1
 displaysleep   2
 acwake     0
 lidwake    0
~ ‹›  $ 

Solution 1:

By default, the MacBook actually copies its RAM to disk any time it enters sleep mode (called Safe Sleep). You'll notice this because when you close the lid on your MacBook, there will be a few seconds before the light on the front starts flashing. When the battery gets to 0%, all the computer needs to do is power-off, since the RAM state has already been saved.

This makes me wonder if the problem is happening anytime you return from sleep, or only when the battery hits 0%.

I had similar issues on my MacBook, where the laptop wouldn't return properly from sleep mode. These have gone away for me since disabling hibernate and disabling lid wake.

Many people with SSD disks choose to disable hibernate as the process of Safe Sleep causes a lot of extra writing to the disk (and SSDs have a limited writable lifespan). Since you've upgraded to 8 GB, the laptop is writing 8 GB to disk each time you close the lid.

Note that disabling hibernate will also let your laptop enter sleep mode instantly when you close the lid (something I really like). You'll also recover 8 GB from the sleepimage file, which is pretty valuable on a 128 GB drive.

The only concern is that disabling hibernate will be a problem for you if you actually do hit 0% battery frequently. In this case, it will be as if the laptop had been powered off (crashed). That's not the end of the world, but you will lose any unsaved documents you may have been working on. The solution: don't let your laptop get to 0% battery and shutdown the MacBook when you know it will be off for an extended period of time.

Disabling lid wake prevents the laptop from returning from sleep until you hit any key. I believe this is what actually solved my display issues, but I'm not sure since I did both.

In any case, here's what I suggest for people with an SSD:

sudo pmset -a hibernatemode 0
sudo pmset -a disksleep 0
sudo pmset -a lidwake 0
sudo rm /var/vm/sleepimage

Confirm the settings with sudo pmset -g.

You can find more tips to optimize your MacBook for your SSD here: http://sysadmin.flakshack.com/post/9253439680/ssd-tweaks-for-mac-os-x

Solution 2:

I don't have any definite answer, but only the following hypothesis.

Here is the information we know:

  • When hibernating, all the information in RAM is copied to the disk, and copied back from it when waking up.
  • Your machine has a graphics card that uses the main memory as its RAM.
  • The artifacts you show are a sign of graphics data corruption.
  • Computers that don't have shared memory don't have such corruption problems, and don't store their GPU-dedicated RAM to the disk (as the size of the sleepimage disk image containing the data clearly shows).

From this, here is my hypothesis: graphics data is supposed to be reconstructed on wakeup, but is not in your case because the graphics card believes it already has fresh data, since its RAM cache is populated. Only some applications have a problem because they don't require an explicit cache flushing upon wakeup.

Solution 3:

This is a long-shot, but try resetting your PRAM: reboot while holding down command-option-P-R and hold those four keys down until it reboots again.

Believe it or not, some of the old PRAM settings are still used, particularly for display configuration. Again, its a long-shot, a bug in Apple's display drivers is more likely, but its an easy thing to try.