登录延误和受损的字体在Mac OS X 10.3缓存

At some point a few weeks ago, I noticed my iBook had developed a problem: whenever I logged in, I’d get the SPOD1cursor, spinning on an empty desktop, for about 90 secondsOnly after that would my login proceed: menu bar, Dock, Finder, login items launchingOther than this delay at login, however, nothing else seemed awry.

In fact, the first few times this happened I wasn’t sure if anything at all was out of the ordinaryI often go many days without logging out, and when I do, it’s typically because my virtual memory swap files have grown large enough that a log-out/log-in cycle seems called forI thought perhaps the SPOD was being shown while the system cleaned up my old swap files, or performed some other housecleaning-type periodic task.

I realized something was definitely wrong, however, when I determined that this delay occurred every time I logged inA few days ago, I tried rebooting, logging in, and then immediately logging out and back in againEven then, I had to suffer through the delay.

显然,某些事情是错误的但是什么?

这不是一个错误的登录项目(a.k.athe “startup items” specified in the Accounts panel in System Preferences) — the delay occurred even if I suppressed them by logging in while holding down the Shift key.

Googling for “slow login mac os x”, “login delay mac os x”, “login spod mac os x”, and so forth turned up nothing that seemed applicable.

A corrupt preference file, perhaps? I made an archive of my regular Preferences folder (in the Library folder in my user’s home account), threw out my old Preferences folder, then logged out and back in, letting the system create a factory-fresh set of preferences没有帮助——登录推迟仍在。

足够的猜测I went to another machine, and connected to my iBook via ssh using TerminalLogging in remotely via ssh is enabled using the Remote Access checkbox in the Sharing panel in System PreferencesIn Terminal, from another Mac on your local network, type:

ssh(电子邮件保护)

(对我来说,这是ssh(电子邮件保护)。)

现在我可以用了最佳, a command-line program analogous to Activity MonitorIt lists all the processes running on the machine, and provides information such as how much memory and processor time they’re using.

我回到我的iBook,退出并重新登录The SPOD appeared, and I went back to the other Mac (the one where I was connected via ssh to my iBook) to see what top showedSomething was going on while the SPOD was spinning, and I wanted to know whatUnder ordinary use, it’s convenient and natural to think of Mac OS X as “the system”But on the inside, in terms of how things really work, there’s no such thingAs a Unix-y operating system, the Mac OS X “system” is really a bunch of small processes that work together, each of them doing their own little thingSo what I was looking for in top was a process using a lot of CPU while my iBook was doing its SPOD-for-90-seconds-on-login thing.

And, bingo: ATSServer was getting most of the CPU cycles that weren’t being consumed by top itself.

幸运的是,我知道“at”在“ATSServer”代表:Apple Type Services根据这个chart of Mac OS X’s system servers and daemons, ATSServer is the “Apple Type Solution server, enabling system-wide font management.”2

所以某种字体问题是根本原因I hadn’t added any new fonts recently, so my guess was that it wasn’t one or more damaged fonts, but rather damaged font cachesA bit of Googling turned up这个PDFdocument from Apple, “Advanced Typography With Mac OS X”, which Google conveniently offered todisplay as HTML从这个文档:

删除字体缓存

If your fonts are garbled, or if there are fonts that won’t empty from the Trash even after you restart your Mac, try deleting the Mac OS X font caches.

你可以手动查找和删除这些文件:

  • /系统/图书馆/缓存:
    • fontTablesAnnex
      (fontTablesAnnex contains the character encodings/mappings for all of the fonts on your systemInformation in this file can lead to garbled text.)
    • com.apple.ATS.System.fcache
    • com.apple.ATSServer.FODB_System
  • 在/图书馆/缓存:
    • com.apple.ATS
  • 在您的主目录的图书馆/偏好文件夹:
    • com.apple.ATS.plist

在我的例子中,这个问题被贬低了/系统/图书馆/缓存/ fontTablesAnnexNone of these cache files are essential, however, so I deleted them all(The “com.apple.ATS.plist” prefs file, on the other hand, tracks, among other things, the disabled fonts you’ve specified using Font Book. I left this in place.)

I restarted — not just logged out, but restarted — immediately after trashing these filesLogging in to my account now took only a few seconds.3

However, I remain unconvinced that this has actually solved the problemMy problematic “fontTablesAnnex” file was over 64 MB; upon restarting and logging in, my newly-rebuilt “fontTablesAnnex” file was only 1 MBHowever, each time I logged in, it seemed to grow by another 400 KB, and at other times it seemed to grow significantly while I’m logged in.

Within two days, it had grown to 32 MB — although admittedly, during that time I’d been logging out and in repeatedly, as well as poking about my fonts — and logging in to my account again became slowI deleted “fontTablesAnnex” a second time, and normal log-in performance has been restored (again)If anyone has any suggestions as to what may be causing this, let me know.

有趣的问题

This strikes me as a troubleshooting session that most Mac users never could have managedMost have never even heard of top or ssh, let alone would have known how to use them to see what was going on while the SPOD was displayedBut trickier still is this: what could I have done if I didn’t have a second computer from which to ssh into my iBook?

更新: 凯文·巴拉德埃弗雷特豪(love that username) both wrote to point out that fast user switching allows you to monitor your login with top without using a second computer. Everett writes:

Here’s a possible solution:  Create a second user account on your iBook启用快速用户切换Log out of your main account, and log in to the new account打开终端,并运行

top -l 120 -n 5 -o cpu

- l” will make top print its output to the terminal (instead of its usual behavior of writing over the same part of the terminal each time it updates)特别是, ”- l 120” will make it print its output for 120 iterations before stopping; since the default delay between sampling the processes is 1 second, this will give you two minutes of data“-o cpu” will make it sort output by CPU usage“- n 5“将输出限制在前五个进程。

While top is running, use fast user switching to log in to your usual accountAfter your unusually long startup, switch back to the new account and see what the top output looks like.


  1. 旋转的死亡披萨。↩︎

  2. 所以,从技术上讲,我对“ATS”中的“S”代表什么是错误的,但我认为它是与字体有关的系统组件。↩︎

  3. Those of you who religiously delete font caches every time you install a system or security update, feel free to smirk smugly.↩︎