Sluggish iChat, Messages, Terminal, and Others in Mac OS X Lion

After about 60 days using my MacBook Pro running Mac OS X Lion (10.7.3), I saw some sluggishness in some apps. At first, it was Messages (iChat replacement for Mountain Lion). It went unresponsive and displays the rainbow wheel for a few seconds, enough to annoy an impatient user.

Then, the same behavior happened in Terminal. This is where I realize the common behavior. You know, when you press delete on an empty prompt, you get a bell. The default is the audible bell. When I change it to the visual bell, sluggishness disappeared.

On Messages, I had the default sound effect setting when messages are received or sent.

Boy was I right. In the log /var/log/system.log there were a bunch of these:

May  3 22:30:57 ADYMAC iChat[66352]: [Warning] Actions: Couldn't create SystemSound from /Applications/iChat.app/Contents/Resources/Received Message.aiff
May  3 22:31:07 ADYMAC iChat[66352]: [Warning] Unable to find a sound action ID for /Applications/iChat.app/Contents/Resources/Received Message.aiff  errorResult: 268435460
May  3 22:31:07 ADYMAC iChat[66352]: [Warning] Actions: Couldn't create SystemSound from /Applications/iChat.app/Contents/Resources/Received Message.aiff
May  3 22:31:17 ADYMAC iChat[66352]: [Warning] Unable to find a sound action ID for /Applications/iChat.app/Contents/Resources/Received Message.aiff  errorResult: 268435460

These are when I tried to change the system bell using the System Preferences application.

May 11 01:45:55 adymac System Preferences[44495]: Error 268435460 setting AlertSound
May 11 01:53:22 adymac System Preferences[44678]: Error 268435460 setting AlertSound
May 11 01:58:20 adymac System Preferences[44678]: Error 268435460 setting AlertSound
May 11 01:58:25 adymac System Preferences[44678]: Error 268435460 setting AlertSound

And so I tried a lot of things, including logging out then in, inspecting the file permissions, and also ran the verify permission utility on the hard disk using Disk Utility. Nothing worked.

Finally, I saw that there was one process called coreaudiod

_coreaudiod    45197   0.0  0.1  2453172   5228   ??  Ss   Fri02AM   0:10.52 /usr/sbin/coreaudiod

And so I tried killing it:

$ sudo killall coreaudiod

And as expected, it respawned itself and all audio effects were now working. Sluggishness and the dreaded rainbow wheel are gone.

Googling after, I saw that people mentioned that this may be a bug, and killing coreaudiod is only a workaround not the solution.

Come to think of it, it also caused unnecessary delay when making screen shots using the Command-Shift-4 key combination.

I hope this can save you some time.

Build LFTP on Mac OS X Lion

If you’re a seasoned Linux SysAdmin, you’ll miss LFTP. It’s a really powerful FTP client. Yes, you can also install it using MacPorts or Fink but right now, this is much quicker for me.

Here’s how I built LFTP 4.3.6 on my MacBook Pro. For the record, I’m on 10.7.3

Prerequisite: Apple developer tools (Xcode)

1. Download The GNU Readline Library (The library that came with OS X will not work). This is how I built Readline 6.2:

$ cd /where/readline/was/extracted
$ ./configure --prefix="/usr/local" --disable-shared && make && sudo make install

This will build a static library and install in it /usr/local

2. Make sure the library (libreadline.a) was built successfully in /usr/local/lib

3. Download LFTP and build it:

$ cd /where/lftp/was/extracted
$ CXXFLAGS="-O0 -Wall -fno-exceptions -fno-rtti -fno-implement-inlines" \
LDFLAGS="-Xlinker -search_paths_first -L/usr/local/lib" \
CPPFLAGS="-I/usr/local/include" \
./configure --with-openssl --disable-shared --disable-nls
$ make && sudo make install

In the lftp configure line, the “-Xlinker -search_paths_first” is necessary so that the linker will not prefer the system shared /usr/lib/libreadline.dylib to the static libreadline.a we just compiled.

The final binary will be installed into your /usr/local/bin/lftp and if your build was successful you should be able to run “lftp” and get the prompt:

lftp :~>

My LFTP version:

LFTP | Version 4.3.6 | Copyright (c) 1996-2012 Alexander V. Lukyanov
 
LFTP is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with LFTP.  If not, see <http: //www.gnu.org/licenses/>.
 
Send bug reports and questions to the mailing list lftp at uniyar.ac.ru.
 
Libraries used: Readline 6.2, Expat 2.0.1, OpenSSL 0.9.8r 8 Feb 2011, libiconv 1.11, zlib 1.2.5

Good luck!

Perhaps some of you arrived by searching for “error: ‘rl_kill_full_line’ was not declared in this scope”. Yep, the above steps should help you.