Why does Mail.app take three minutes plus to open?
For some time now, Mail.app takes three minute or more to display its window, and for that interval, is labeled "not responding." There are several things that are related somehow:
- During that interval, fseventsd consumes 82%±3% of CPU.
- If we run
/usr/sbin/repairHomePermissions
, Mail launches normally, but the fix only lasts a couple of days. - If we rebuild mailboxes, it is not fixed; if we remove all the IMAP accounts and reinstall them, it is not fixed; but if we rebuild mailboxes after that reinstall, it is normal, but again, only for a day or two.
- If we remove everything from
/Library/LaunchDaemons
, and reboot, it works normally. Did that today, so I don't know yet how long it will last.
Here is what was in LaunchDaemons:
com.acapelagroup.iVoxHelper.plist
com.adobe.ARMDC.Communicator.plist
com.adobe.ARMDC.SMJobBlessHelper.plist
com.apple.installer.osmessagetracing.plist
com.barebones.authd.plist
com.malwarebytes.HelperTool.plist
com.malwarebytes.mbam.rtprotection.daemon.plist
com.malwarebytes.mbam.settings.daemon.plist
com.oracle.java.Helper-Tool.plist
com.paragon-software.installer.plist
com.paragon-software.ntfs.loader.plist
com.paragon-software.ntfsd.plist
com.prey.agent.plist
homebrew.mxcl.dnsmasq.plist
homebrew.mxcl.mysql.plist
homebrew.mxcl.unbound.plist
org.macports.rsyncd.plist
I believe all of that has been around for longer than the problem. I recently got a new 2019 MBP with Catalina, upgraded to Big Sur, and used Migration Assistant to bring everything in from a 2012 MBP with Catalina. This problem never occurred on the old MBP, and I think (not certain) that it did not start immediately on the new one. I'm fairly sure I used it for weeks before this started happening.
Ideas? It's going to take two days to find out whether removing some LauchDaemon is a permanent fix, and if so, weeks to figure out which one. And it would still be a mystery how it interacts with permissions and mailboxes.
fseventsd is known to suck up CPU for Time Machine, but this problem has happened with Time Machine turned off and when the TM disks aren't even plugged in. And opening Mail should be making roughly the same disk actions each time it is launched.
https://arstechnica.com/gadgets/2007/10/mac-os-x-10-5/7/
https://discussions.apple.com/thread/1502226
Another oddity (but I think it's unrelated) is that Photos.app is allegedly using a lot of energy when the Dock, ps -ef
, and Activity Monitor all say Photos is not running. (Though sometimes, photoanalysisd
appears in Activity monitor briefly.)
UPDATE: After an O.S. update, most of the time, Mail opens instantly, and when it doesn't, the delay is only a few seconds (never the five-plus minutes from before). However, once in a while, for no obvious reason, a Finder action seems to take minutes!
Let’s see what Mail is doing:
- Run the following Terminal command to enable kernel symbolication:
$ sudo nvram boot-args="keepsyms=1"
- Reboot your machine and don’t open any apps except for Terminal.
- Open Mail and wait a few moments for it to reach its steady-state unresponsiveness.
- Run the following command in Terminal, making sure you’re only running it during the window of time that Mail is unresponsive:
$ sudo spindump -reveal -noProcessingWhileSampling
- After waiting for 10 seconds to collect a sample and another minute or two to symbolicate and format, you’ll get a file in
/tmp/spindump.txt
that contains a stackshot of every process. - Upload the file to PasteBin or some equivalent place and we can take a look to see what Mail’s main thread is blocked on.
I had this problem as well and as a bit of a last resort, I actually installed CleanMyMac X to see if they had any recommendations. I'm normally extremely wary of this sort of ambiguous "cleanup" software after the CCleaner fiasco (and some of the stuff CleanMyMac suggests doing looks insanely dangerous from a developer perspective, like randomly deleting portions of applications like localization files and alternate architectures; I need to learn why this doesn't instantly break code signatures & gatekeeper).
But I digress. I tried their "mail attachments" cleanup and … suddenly Mail.app launches within seconds again. I think you can do this yourself by manually clearing out your "Mail Downloads" folder. I think there might be multiple causes for launch slowness but this did reliably fix mine.