Firefox 3 for Mac OS X: Under the Hood

Josh and his grandfather RolandFirefox 3 will be released soon (get the RC here). While the release contains a huge number of new features and performance improvements for all platforms, it is particularly significant for Mac OS X users. We rewrote most of the Mac OS X code that was behind Firefox 2 in order to benefit from modern Apple technologies and fix long-standing bugs. Once you try it I think you’ll agree that the results are astounding. I’d like to explain what exactly we did in this rewrite, how Firefox 3 for Mac OS X is different “under the hood.”

Before I start, I need to explain Gecko vs. Firefox for anyone who doesn’t already know. Gecko is the engine behind Firefox. It provides the capabilities that we use to build Firefox. Under the umbrella of Mozilla, Gecko is actually a much bigger project in technical terms than Firefox is. For example, there is much more Gecko code than there is code specific to Firefox, which is an application we built on top of Gecko. Firefox and Gecko have different version numbers – Firefox 2 uses Gecko 1.8.1 and Firefox 3 uses Gecko 1.9. This post is about changes we made in Gecko 1.9, the engine behind Firefox 3.

The biggest change is that Gecko 1.9 is based on Cocoa instead of Carbon on Mac OS X. There has always been a lot of confusion about what this means, particularly since Gecko 1.9 also happens to include Aqua form controls. It may seem strange to some, but Gecko’s new Cocoa underpinnings and its Aqua form controls are almost completely unrelated.

There are only 2 types of Cocoa objects at the heart of Gecko 1.9 on Mac OS X (let’s forget about the menu bar at the top of the screen for now). Cocoa’s NSWindow allows us to make and control a window on the screen and Cocoa’s NSView allows us to draw things into a window. Those two objects also allow us to get most of the events we need to know about from the operating system (such as key and mouse events). We do not use actual Cocoa buttons or any other Cocoa controls within any Gecko 1.9 windows. The context menus, dropdown menus, the toolbar, the search bar, the buttons and text fields within web pages – they are not actual Cocoa controls. For example, instead of using actual Cocoa buttons for “Submit” buttons we just draw the image of an Aqua “Submit” button into an NSView, one of the basic Cocoa objects we use. Gecko 1.9 has Aqua form controls because we now draw images of Aqua form controls when appropriate, not because we use actual Cocoa controls. The reason we don’t use actual Cocoa controls isn’t because we are lazy or we can’t figure out how to use them or because we are constrained by our cross-platform requirements – Apple’s WebKit doesn’t use actual Cocoa controls for things like “Submit” buttons or popup buttons in web pages either, at least not the last time I checked. IE for Windows is in the same boat. The reason Gecko 1.9 doesn’t use Cocoa controls is for the sake of flexibility – form control behavior and appearance can be changed significantly via HTML, CSS, and JavaScript. Actual Cocoa controls are simply not flexible enough to do all of the things that people want to be able to do with controls on the web.

So if we didn’t get Aqua form controls out of the deal why did we do the Cocoa rewrite? First of all, Apple has deprecated much of Carbon already1 and has made it clear that Cocoa is the future for Mac OS X applications. Apple is investing heavily in Cocoa, which benefits us if we use Cocoa. Cocoa also gives us access to great features that would be more difficult or impossible to take advantage of through Carbon. For example, with Cocoa we were able to relatively easily draw using CoreGraphics instead of the ancient Quickdraw API (more on this later). Secondly, the Cocoa way of doing things matches up with the Gecko way of doing things better than Carbon did. Our Cocoa code is easier to understand and maintain because of this2. This will result in faster development and fewer bugs in the long run. In fact, we actually added more capabilities to Firefox 3’s Gecko 1.9 (such as transparent windows, unified toolbar windows, and an alert service) than we have ever added in any release of Gecko since Firefox 1.0. This is in addition to doing a huge amount of work just to re-implement many of the features that Gecko 1.8.1 had already implemented in Carbon!

Another major under-the-hood change in Gecko 1.9 for Mac OS X is drawing via CoreGraphics and ATSUI instead of Quickdraw. Like much of Carbon, Quickdraw is deprecated and does not exist in 64-bit Mac OS X. Gecko 1.9 uses the Cairo library on all platforms, and Cairo draws with CoreGraphics and ATSUI on Mac OS X. The CoreGraphics drawing API is modern and hardware accelerated, a huge improvement over Quickdraw in terms of speed, capabilities, and code clarity. In addition to using CoreGraphics ourselves, we have made it possible for plugins to use CoreGraphics via NPAPI Drawing Models3. Flash is already prepared to take advantage of this new capability in Gecko 1.9! As for text, using ATSUI allowed us to improve our text kerning and ligature capabilities. It also gives us better glyph cluster positioning, which is good for Indic languages and languages that use exotic combining marks.

I hope this helps to shed some light on why Firefox 3 is a particularly significant upgrade for Mac OS X users. I’m really proud of what we accomplished with this release, it was ambitious and things worked out well. Kinks remain as with all major revisions, we’ll be addressing those quickly in minor updates to Firefox 3.


1 While the deprecated Carbon API is still available for 32-bit applications like Firefox 3, it simply won’t be available to 64-bit applications. Firefox 3 for Mac OS X will not be available in 64-bit but we’re preparing for 64-bit by removing code that won’t work in 64-bit.
2 It might be true that on the whole our Cocoa implementation is more complex than our Carbon implementation was, but that is because our Cocoa implementation does far more than our Carbon implementation ever did. The Cocoa code is still more readable and maintainable.
3 See the NPAPI Drawing Models spec.

54 thoughts on “Firefox 3 for Mac OS X: Under the Hood

  1. But what about Core Text ( instead of ATSUI?

    I am asking because the same signal of deprecation applies equally to Carbon and to ATSUI and some other stuff as well. Read what John Siracusa said: “Core Text replaces the confusing alphabet soup of text APIs in Mac OS X Tiger and earlier, mostly inherited from classic Mac OS: ATSUI, MLTE, and QuickDraw text.”

  2. Cool, thanks for the notes. My biggest concern with FF 2.x has been its performance if I leave it running for a long time. After a while, although VM growth isn’t recorded, the app basically becomes non-responsive. This is particularly noticeable when I click on a link that takes me to one of their affiliated sites with the “15 best xyz”, and I try paging through those 15 links.


  3. What’s keeping me on Safari instead of using Firefox is the fact that, in spite of all of this Cocoa goodness, Firefox still does not seem to be able to use the Services menu that is available to all other Mac apps (

    Related, I suppose, is the fact that I can’t select text in Firefox and automatically send it to LaunchBar – this is the true showstopper for me.

    Are there plans in the works to address that?

  4. One issue I’ve noticed with Firefox 3 (all the way up to the current release candidate) on Mac is that after browsing for a few hours, the browser seems to “break”.

    Pages load incomplete, images don’t appear, and even Firefox -> Quit doesn’t exit the browser and I have to right-click the dock icon and select quit to exit it.

    I filed this as a bugzilla bug (424337) but nobody has commented on the bug, so I’m not sure it’s being seen by the appropriate people.

    I figured I would bring this to your attention, since you are one of the developers; this issue has occurred on both of my Macs so it doesn’t seem to be specific to one machine.

  5. Nice to hear, that you made more than just a new (and quite gross 😉 ) UI for the Mac. I think it’s a good step to keep “cross platform” but integrate it better into the OS. I hope KeyChain integration will come next 😉
    One other little question: Does Gecko 1.9/FF3 use the Sandboxing features on Leopard as Safari does?

  6. Can I compile stock FF3 on Mac to be 64-bit?
    I think I need 64-bit to run Java 6 applets.

    Concise answer appreciated.

  7. Hey, Why no support for Mac OS 10.3 or earlier ???? This is not very fair !

    Windows 2000 is supported and old pentiums also.

    I cannot install 10.4 on my mac (no Firewire). I may not be the only one in this situation. Mac Users are not necessary rich guys or addicted geeks that always have a brand new Hardware.

    Please can you send this message to the Firefox team ?


  8. Just a quick thanks! Us Mac users really appreciate what you guys have done. I just wish I could use my Mac at work…stupid Windows XP.

  9. Great job ! I can notice the difference with ATSUI I guess on large arabic text display for instance. But since beta versions of fx3, I’ve experienced the same slowdown (and extensive fan activity) as Zorin with my PowerBook G4 (Tiger), with top command reaching 70% on very simple sessions (4 or 5 concurrent tabs ). A since I still use fx2 for heavy work….
    Thank you again

  10. Are you working on fullscreen support for firefox on Mac OS X. This is a real limitation at this point. Lots of Mac applications have true fullscreen support so it should be possible.

  11. “Can I compile stock FF3 on Mac to be 64-bit? I think I need 64-bit to run Java 6 applets.”

    We cannot produce 64-bit builds of Firefox for Mac OS X at this time. There is a lot of work that needs to be done there and we’re on it, but it’ll still be a while. I don’t know about Java 6 and how it relates to the question of 64-bit.

    “Hey, Why no support for Mac OS 10.3 or earlier?”

    Apple evolves very quickly. Mac OS X 10.3 does not do many of the things we need it to do and we don’t have the resources to offer support that far back.

    “Are you working on fullscreen support for firefox on Mac OS X.”

    We are working on it though admittedly it is not a high priority task.

  12. Hey, great work on ff3, it’s awesome!

    My bug report: dragging an image from a webpage onto Photoshop in the dock doesn’t work. Says it’s not the right type of document. I would love to have this work…

  13. Dustin, that’s possibly the same thing as bug 433093. Without being able to see the insides of the receiving app (or documentation on what flavors it wants), though, it’s really hard to know what the problem might be.

  14. The main thing that keeps me on Safari, and likely will continue to, is the lack of text system integration. I use and rely on the ability to lookup words in the dictionary/thesaurus with a keystroke (FF3 doesn’t even let me select the word and then use context menu, as that’s custom too), and the inbuilt spell checking in text entry areas. I know gecko has its own spellcheck, but why have to maintain a separate custom dict, etc. if all my other apps use the one provided by the system?

  15. When I drag and drop a photo from a website to the desktop in Tiger, it won’t drop where I’ve indicated and snaps to the desktop grid. If I drag/drop a photo into a folder… the folder is snapped to the grid most of the time… while at other times it is sent to the middle of the screen. Firefox appears to be the only browser that behaves this way and it’s quite annoying.

    Has anyone experienced this issue with Leopard?

  16. I have the latest build of 3 (still waiting for the final release today though) and am on Tiger 10.4.11. I am experiencing major problems: response often very slow – prevents me from moving the browser window around until the processor has slowed up again. Simple re-sizing of the Firefox window causes a huge spike in processor activity (fans whirr madly etc) – whilst this is going on Firefox is of course completely unresponsive.

    Something’s definately not right – all other browsers (safari 3/opera etc) and apps perform normally, so this is definately a firefox 3 specific problem.

    I hope things will work better with the public release version today!

  17. I really appreciate all the work that has gone into the Mac version. One thing that still bothers me and a lot of other Safari users though is the fact that Firefox can’t seem to scroll properly. Choppy with smooth scrolling turned off, laggy if on.

    I’ve been using Safari 3 as it’s noticeably faster than firefox 2. I was going to switch back to firefox 3 since the RCs but noticed the lag straightaway after getting used to safari’s silky smooth scrolling.

    However, once all extensions support ff3, I will probably switch back anyway. But it’d be nice if firefox can scroll as smoothly as safari.

  18. Pete. I had the same slowdown issue on my imac g5 at home. The browser would stall. Big problem. This was a straight copy over Firefox2. I decided to do the bookmark backup. Then delete EVERYTHING that was for Firefox/Mozilla on the machine. I then reinstalled. I’m now no longer having any slowdown issues. Of course this is bad for less technical users.

  19. I agree about services. It shouldn’t be too difficult to add that in and Apple has plenty of documentation on how to do this. Services feature has been around for more than 4 or 5 years. What’s the holdup here???

  20. Major issues on my end with scrolling and CPU, especially on pages with any type of Flash. If a second or third window with even a small Flash ad is open, it dramatically slows down the scrolling, causes the CPU to spike, and heats my iBook G4 (1.33 GHz) (runs Leopard). This is NOT a bug I expected to be allowed into FF3, but I guess I shouldn’t be surprised. It’s absolutely disappointing.

  21. What is going on with the font rendering in FF3 on Mac OS X? Specifically, light text on top of a dark background looks bold, even when the font-weight property is set to normal. Firefox 2 did not have this problem. Firefox3 for the PC does not have this problem. Firefox3 for OS X seems to be the only browser rendering larger text bolder than it should be. This has made my company’s website look TERRIBLE. We have literally been searching for a solution for the past 18 hours and have not been able to find anything. Please give us some insight as to why this is happening. What would have changed from FF2 to FF3 on OS X that would cause font rendering to be so distorted and inaccurate?

  22. I’m loving the new fox – but I do sincerely hope that true fullscreen becomes available, whether it’s part of the package or as an extension.

    Saft for Safari gives me true Full Screen, but Firefox would be perfect if it did the same.

  23. I’m having problem with text encoding/font rendering on certain sites such as wikipedia. Instead of seeing letters from correct alphabet/legible font, I’m seeing unicode/cyrillic looking alphabets. It only happens on certain sites, and on these sites the words are completely illegibe. Another strange thing is that it mess up the safari’s capability to display letter correctly as well. Anyone has any clue?

  24. Services menu certainly works for me on FF3 in 10.5 … did you actually try it?
    To flash problems: I really wouldn’t blame that on FF3, I think it’s quite widely known that flash is an obnoxious resource hog and that the mac os x implementation is especially bad.

  25. We cannot produce 64-bit builds of Firefox for Mac OS X at this time. There is a lot of work that needs to be done there and we’re on it, but it’ll still be a while. I don’t know about Java 6 and how it relates to the question of 64-bit.

  26. The services menu is not working for me either. You might get the menu, but all the options are grayed out. I need it to easily clip text to my notetaking application.

  27. Vincent, i have the same problem. wikipedia and slashdot among others.
    looks like tiny numbers with lines over them or something.
    i hadnt even realized that it killed safari too.
    wtf do we do?

  28. Hi,

    OT question. I am new to Cocoa and want to get some advice from you. How do I program a text input that behaves like the address bar in FF3.
    1) auto complete from history
    2) Drop down list of history from the “down arrow” icon at the right.


  29. Vincent, I too had the same font display issue(Craigslist was horrific). My solution was to change the default font from within Firefox (Firefox / Preference / Content / under Font & Colors), for instance from “Times” to “Times Roman”. Wish I knew the cause of the problem for something so simple–for is it my Mac, or a corrupt font, or a Firefox? But this is the work around.

  30. Hey Josh: FF3 doesn’t use ATSUI for it’s about box and chrome.
    For an example try using an indic localisation and you’ll see that the ZWJ/ZWNJ glyphs aren’t suppressed, and vowels aren’t rearranged. This problem does not occur on actual web pages in FF3.

  31. Seems like I’m having the same problem as edgeoforever. I’ve installed firefox 3 on my mac and everytime I try to open it, it closes down. The small black upsidedown triangle underneath the FF icon (in the dock) signals to me that its opening for about a second then disapears. I have no idea why this is happening as i have followed the installation guide on their website (eg: copied FF to my apps folder etc). I’d be greatful for any infomation on how to fix this problem or if someone could shed some light on something I’m doing wrong. Thanks.

  32. Talking about Firefox and Safari, I think they both are kinda equal…And its true that now it seems impossible to produce 64-bit builds of Firefox for Mac OS X. We in Russia trying to make something out of this:)By the way, I dont have problem with Firefox scrolling,goes pretty smooth:)

  33. Hi, people,
    I ran into a problem: Firefox 3 for Mac diplays a drop content bug on our site:
    It is similar to the 3 px drop bug in IE6 for which I had to use a proprietary hack.
    The problem only shows in the Firefox 3 for Mac version. Firefox for Windows is fine. I would appreciate any of your insight into how I can combat this in Firefox 3 for Mac. Is there any kind of proprietary code I can use? thanks.

  34. Fullscreen support for FF3 on OS X *should* be a priority – us designer types (you know, the ones who own macs? Ostensibly the people you’re developing FF3 on OS X for…) eat up fullscreen mode for the presentation enhancements that if gives when previewing work. A number of the designers that I’ve worked with load parallels on the machines of their art directors specifically so that they can demo live web work using fullscreen mode.

    Bringing it in would be a boon, and remove the whole pesky virtualization thing (for what I would consider to be a defining feature that’s conspicuously absent on a major platform).

    I’m sure there’s a good reason that it’s missing, but certainly, it’s not an insurmountable challenge to include it, is it?

    I, and many others, would love you long time (and further aim to promote the dominance of FF).

  35. Sorry – edit to the above. The somewhat confusing sentence about designers and parallels should have read:

    “A number of the designers that I’ve worked with load parallels on their machines specifically so that they can… etc.”

    My non-linear comment writing is catching up with me again, and annihilating what little coherence I manage to hang onto through all of the whiskey 😉

  36. I’m using identical builds of the latest download of FF 3.0.5. on an Intel Mac on 10.5.6, and on an old white iBook G3 on 10.4.11.
    – Why won’t it load images from Wikipedia on the IntelMac? I am now forced to go back to using safari.

  37. I have consistently noticed on all editions of Firefox (w/o any 3rd party-installed add-ons) on all my machines (G4 / dualG4 / dualG5 / Intel Core2Duo Mac) is behaving the same way… (even on a Freshly installed OSX — used Tiger and Leopard and from v2 until the latest v3 Firefox)

    – Flash animations and actions are slow and choppy.
    – Java script (IRC) tend to have display problems. Images disappearing w/in the Java applet.

    What’s odd is that in Safari, none of these behaviors show.

  38. FF3 for mac freezes and crashes after a couple hours of use. Especially on facebook and myspace. FF2 did this too. So dissapointed. Please fix. Plus it’s a resource hog. Losing faith.

  39. “Apple evolves very quickly. Mac OS X 10.3 does not do many of the things we need it to do and we don’t have the resources to offer support that far back.”

    Well maybe WE ALL don’t have the resources to buy a million goddamn new computers. You’re forcing us to turn perfectly good 4-5 year old systems into toxic e-waste, coz a newer OS won’t run decently on it.

    “don’t have the resources” – then what was the 55 million dollars Mozilla got from Google Adwords? Couldn’t you, like *pay* someone to do the dreary scut work volunteers can’t be bothered to do? That’s what most volunteer organizations do…

    I mean, honestly. Who are you writing Firefox for? Regular folks, or you “replace your computer every year” digirati? Grrr…. I thought the whole POINT of the Mozilla foundation was internet democracy and access to all. Yes it’s true you look at your access logs and don’t see a lot of older OS’s… but this is self-fulfilling.

    What, “use firefox 2 then”? Two problems. #1, security is no longer being maintained, so that’s the road to getting hacked. #2, modern Web application writers think the same way you do, and demand/require more modern browsers.

    So who is in the best position to help with gap between web applications and consumer hardware/OS? Ding. The browser folks.

  40. We’re starting to notice on the Mac OS that Firefox 3.x is not properly handling applet window updates. Our applet is sending the display.repaint() call; the OS is not returning applet.update().

    Jmol to OS: display.repaint(); // tell the OS to upate the page
    OS to Jmol: update(); // tell Jmol to construct a new screen buffer and display it in the window.

    Our crude test at repeats endlessly until this quirk appears. The OS just doesn’t return Jmol’s call. No other problem with other operating systems that we know of.

  41. It still amazes me how powerful firefox is as an open source software. I love the fact that you can customize and build firefox into such a powerful application even moreso than a browser due to all the extensions you can add.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s