Lion's Preview regularly hangs when unhiding with open documents

Solution 1:

I’ve been having this problem in Lion, and the only workaround I’ve found is to disable Resume, on a once-off or total basis for Preview.


Disabling Resume permanently

If you open Terminal (/Applications/Utilities/Terminal.app), and enter the following string, then Resume for Preview will be disabled permanently:

defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool false

You can also disable Resume for all apps in System Preferences: in the General pane, untick the checkbox marked Restore windows when opening and quitting apps. I find Resume generally useful, so I haven’t, but you might want to do this.


One-off disabling or Resume

If you don’t switch it off permanently, and you’re working with a lot of files in Preview, you might not want it to re-open them the next time you launch it. When you quit Preview, hold down the option key; then the Quit Preview command becomes Quit and Discard Windows. Use this, and it won’t reopen all of your files next time. (Keyboard shortcut is opt-cmd-Q).

If you forget to do this when you close Preview, and it starts hanging, then you can flush the Resume data. Navigate to ~/Library/Saved Application State/com.apple.Preview.savedState and delete the file or folder stored there. This deletes all the saved data for Preview, so when you open Preview later, it doesn’t restore any of your saved documents.

This is probably more useful if it’s misbehaving intermittently, than for the problem you describe.


Further comments

  • If you’ve set Preview to never remember your files, you can temporarily get it to remember them. As with the one-off disable, hold down the option key when you quit Preview, then you get the command Quit and Keep Windows.

  • I disabled Resume for Preview shortly after Lion came out, and I’ve not had any problems since. However, I only use Preview for images, not PDFs (I use TeXShop for that), but even so, the hanging is completely gone.

  • You can also have “opt-in” Resume using these steps. If you disable Resume for all apps, then run the Terminal command above with true instead of false, then you can whitelist Resume-enabled apps, rather than blacklist them. You can find the com.apple.Preview equivalent for any app by looking at what the appropriate file is called in the Saved Application State folder. (A quick Google search for Terminal commands involving that app would also do the trick).

I hope some of this is useful and speeds up Preview: it certainly worked for me.