Friday, January 06, 2006

Mail.app hang when mail images from iPhoto - fixed

I have had a very annoying bug with sending images from iPhoto. If Mail.app were not running, my system would hang with a spinning beachball of death (aka SBOD, spinning pizza of death, SPOD) for at least 5 minutes. Then I would get this error message: "mail got an error: apple event timed out". If Mail.app were running, there was no problem.

I tried various fixes such as cleaning caches, testing with different iPhoto libraries, etc. I began to feel the problem was in Mail.app. Stupidly, however, I forgot the standard fix for OS/X problems -- delete the preferences (.plist) file. I did ask on Apple's discussion forum, and I received a helpful response from Robert K:
Apple - Support - Discussions - iPhoto and Mail.app hand on email images ...

> I was having the same problem. Others have advised
> to delete the following file: com.apple.iphoto.plist
> in /users/library/preferences/. This had no effect
> on the freeze. I then deleted com.apple.mail.plist.
> This cured my problem. I did have to set up my mail
> accounts again in mail, but no more freezes when
> sharing a photo from IPhoto and Mail.

Your advice fixed the problem. There were some interesting twists.

I was pretty sure the problem was in Mail.app, not iPhoto, since switching iPhoto libraries had no effect. First I opened com.apple.mail.plist in a plist editor and saved it externally. I figured that would fix any true corruption. Interestingly when copied this file to the Prefs folder and tested I only got the beachball for about 1-2 minutes, then the images appeared. HOWEVER, I then remembered I'd recently set my CPU to higher performance. I suspect there's some odd race condition here and what happened was the race condition resolved before the AppleEvent messages timed out.

Then I deleted my mail prefs file and restored the settings. On testing if Mail.app was running the image appeared instantaneously, if it was not running I got a beachball for five seconds.

So evidently there's some prefs value in com.apple.mail.plist that causes this problem. I have my old prefs file if Apple should want a copy!
So the problem is gone for now, until I do something in Mail.app to alter the preferencess in such a way that the problem recurs. I wonder if it's somehow related to having once had a .Mac account then having discontinued it.

Update 1/9/06:

I may have identified the cause of this bug. We know that deleting com.apple.mail.plist fixes it. But why? What was "wrong" with the original.

I think the trick is to delete the default .mac account for both sending and receiving. When you do that, and try mailing an image, you'll get the beachball and the appleevent error.

I have to guess for some reason Mail.app is trying to do something with the .Mac account, and when it's missing it hangs.

It doesn't matter whether the .Mac account is active or not, it simply has to exist.

No comments: