Sunday, August 12, 2007

Firefox Hangs on OS X

If you experience Firefox hangs on OS X like this guy, use Spin Control to pinpoint the cause. Spin Control detects hung applications and captures stack traces. I assume they named it Spin Control in honor of the spinning beach ball of death.

I've personally experienced hangs as long as a minute on various computers. Slow DNS lookups always seem to be the culprit. Until someone fixes Firefox so it doesn't completely lock up, your best bet is to prevent slow DNS lookups.

In some cases, my VPN connection ended non-gracefully and left my DNS configuration in a bad state, i.e. OS X still tries to connect to the DNS servers on the private network even though I'm no longer connected, and Firefox hangs until the connection times out. An easy solution is to switch network locations thereby resetting your configuration to a good state.

If you still experience problems, you might try switching DNS servers or even installing a local DNS server. I haven't needed to try the latter just yet.

Update: I finally broke down and enabled the local DNS server. I followed the instructions from Mac OS X Hints. Many of the comments claim the hint won't work, but it worked great for me. I went from frequent 3 to 4 second hangs to no hangs at all according to Spin Control.

9 Comments:

Blogger Michael said...

Could you try the Firefox build at Firefox Intel Mac 2.0.0.6 and let me know if there is still a hang problem related to Firefox?

The reported cause of the hang problem was the use of lightweight locking using the x86 CompareAndExchange instruction and the fix was to get rid of the lightweight locking for all platforms (arrggghhhh). The problem was seen on Core 2 Duos on OSX and Windows. This build uses the Apple system call for the compare and exchange instruction without memory barrier protection. I'd like to know if the hang problems go away using Apple's call for the instruction - the simple one. If that doesn't work, then I'd try the memory barrier version of the function to see if that clears the problem.

I've never run into one of these hangs on our MacBook Pro but we've only had it for three weeks.

The build has two other performance optimizations (lightweight float to integer conversions and JPEG IDCT SSE2 acceleration) but those are orthogonal to the hanging problem that I read about.

7:40 PM  
Blogger Vishal said...

Hi, my IBM Thinkpad (Windows XP) slows down a lot on connecting to VPN. Any tips for Windows users?

9:34 PM  
Blogger Amy said...

I'm glad I happened across your post the other day. I tried Spin Control, but I don't quite know how to read the output - how do I tell if it is a DNS problem? My hangs can happen when I'm in the middle of scrolling down a fully loaded page full of *text only*, so I don't really know what it would need to be looking up at that point. The summary at the bottom of the Spin Control report says:

Sort by top of stack, same collapsed (when >= 5):
semaphore_wait_signal_trap 985
semaphore_timedwait_signal_trap 591
mach_msg_trap 397
select 393
kevent 197

But I don't know if that's helpful, or the pertinent part, or whatever.

7:52 PM  
Blogger Bob said...

That thread is just waiting on a lock. Do you see any threads which aren't in a "semaphore_wait?" Is the text big? You could just be low on RAM, in which case it might have to swap the content in from disk.

8:54 PM  
Blogger Lucas Young said...

Hi
I've just noticed the same problem on my Intel Mac Pro - Firefox is now sluggish when clicking links. I trashed it and am using Firefox Intel Mac (Bon Echo) 2.0.0.7 and the problem is still there. I also set up a local DNS server as suggested at http://www.macosxhints.com/article.php?story=20050420025219402 but still no luck. Spin Control is telling me the hang times are 0.8-1.24 seconds. The report says:


1.24s semaphore_timedwait_signal_trap [TOP]

1.24s semaphore_timedwait_signal_trap

1.24s PR_Lock

1.24s PR_WaitCondVar

1.24s nsHostResolver::GetHostToLookup(nsHostRecord**)

1.24s nsHostResolver::ThreadFunc(void*)

1.24s PR_GetSP

1.24s _pthread_body

1.24s Thread_4213

Can anyone tell me what this means?
Many thanks in advance

Lucas

3:53 AM  
Blogger Bob said...

I would double check your local DNS configuration. You remembered to replace the DNS section of your network settings w/ 127.0.0.1?

8:23 AM  
Blogger Lucas Young said...

Ah, you mean in Preferences -> Network? No, I hadn't :) I just changed it and found nothing could connect any more, so I'm going to go through that tutorial again and double check everything. Cheers

12:45 PM  
Blogger Lucas Young said...

Ah, I have a broadband router, so the local DNS setup was a waste of time, all I had to do was point my DNS settings to the router.

2:22 PM  
Blogger Thomas said...

With my MacPro (broadband router) Firefox routinely freezes completely after a couple hours of intense surfing. (I moderate 4 online forums) The machine has 12 gigs of memory...

I have bootcamp installed, running Firefox on XP pro SP3 there are no such hangs/freezes...

11:26 AM  

Post a Comment

Links to this post:

Create a Link

<< Home