Q: Here's how to fix slow user switching on Mac OS X
The short version: change you user picture to one of the defaults provided with the OS to see if this is the problem. Curious? Read on.
I was experiencing general sluggishness related to some aspects of one of the user accounts on a Mac, most notably using Fast User Switching to switch to that account from a different one. I noticed multiple people were experiencing this issue, for example in these threads:
- slow user switching
- Fast User Switching Slow on Mavericks
- Mavericks Fast User Switching: Slow 30 second delay when logging in and logging out of second account
I also tried:
- Clearing all user caches (~/Library/Caches)
- Clearing all user preferences (~/Library/Preferences)
- Removing all user LaunchAgents (~/Library/LaunchAgents)
- Signing out of iCloud
- Removing nonstandard System Extensions
- Repairing System Permissions using Disk Utility
- Repairing User Account Permissions using Recovery Mode (cmd + R on boot), and the "resetpassword" utility in there.
However, none of the solutions were applicable to my situation, or at least did not help solve the problem. I was almost ready to follow this approach to delete and restore the entire user account, when I decided to inspect the directory mentioned in that article: /var/db/dslocal/. Using terminal, I navigated to
mbpvansnjanssen:~ Stan$ sudo -s
Password:
bash-3.2# cd /var/db/dslocal/nodes/Default/users
(using admin rights). Inspecting that directory using
bash-3.2# ls -lh
Reveals this directory listing (plus many other files):
bash-3.2# ls -lh
total 488
-rw------- 1 root wheel 68K 11 nov 21:04 Guest.plist
-rw------- 1 root wheel 4.6M 29 dec 12:49 Stan.plist <--- This is the offending user account
-rw------- 1 root wheel 264B 27 okt 21:58 _amavisd.plist
-rw------- 1 root wheel 258B 27 okt 21:58 _appleevents.plist
-rw------- 1 root wheel 265B 27 okt 21:58 _appowner.plist
I noticed that just about al the .plist files were a few hundred bytes to several kilobytes, but the .plist file for the offending user was over 4 megabytes. This seemed off for a plain-text property list file, so I decided to check it out. Using Property List Editor.app (a tool provided with the Apple Developer Tools), it revealed the following structure:
The highlighted row contains a string-encoded version of the user account picture (the whole picture, every "pixel" of it, is saved in this .plist file, not just the file path). In my case, this was a picture taken from my iPhoto library that was about 4.6 MB in size. I also noticed that Property List Editor (the application I was using to read this file) was really bogging down on this line. I made the connection: this file gets read whenever the system needs to authenticate or access something to do with (switching to) this user account, and maybe reading this plist file is taking tens of seconds!
I decided to change the desktop picture to one of the standard pictures provided. Sure enough, the .plist file shrank to 64 kilobytes:
bash-3.2# ls -lh
total 488
-rw------- 1 root wheel 68K 11 nov 21:04 Guest.plist
-rw------- 1 root wheel 64K 29 dec 12:49 Stan.plist
Now, switching to this user from a different one is just as fast as it should be. I ended up using an image editor to reduce the file size of the picture I used to have and reinstate the smaller version as my user picture. User switching is still really fast and I consider this problem solved.
I hope this helps other people struggling with this! And Apple really should compress the user picture BEFORE string-encoding it into a .plist file :-)
MacBook Pro (17-inch Mid 2009), OS X Mavericks (10.9.5)
Posted on Dec 31, 2015 4:27 AM
