Firefox 4 for Mac OS X: Under the Hood

Looking under the hood of a carFirefox 4 will be an exciting release and we’ve made a number of improvements specific to Mac OS X. Users will benefit primarily in terms of speed, stability, and security. We’ve come a long way since Firefox 3 for Mac OS X.

First, we’ve switched from a ppc/i386 universal binary to an i386/x86_64 universal binary. The default architecture on Mac OS X 10.6 will be x86_64. The default architecture on Mac OS X 10.5 will be i386. You will be able to run in i386 mode on Mac OS X 10.6 if you choose to do so but you will not be able to run in x86_64 mode on Mac OS X 10.5. Performance is the primary motivation for the move to x86_64. These numbers comparing Firefox 4b7 i386 to Firefox 4b7 x86_64 on Mac OS X 10.6.4 give some idea of the kinds of gains we’re seeing from the architecture change alone:

  • Cold startup: x86_64 is ~26% faster
  • Warm startup: x86_64 is ~5% faster
  • MS Psychadelic Browsing Demo: x86_64 is ~540% faster
  • MS Speed Reading Demo: x86_64 is ~35% faster

A big part of this is the availability of more CPU registers, but there are a number of other factors in play such as the ABI and the caching of system libraries. If most of your other applications are x86_64, and this is the case on most Mac OS X 10.6 systems, then x86_64 system libraries are more likely to be cache-hot. Your mileage may vary depending on your exact system configuration.

We dropped ATSUI for text rendering and moved to Harfbuzz and Core Text. The move to Harfbuzz for many operations was done for security reasons and in order to expose advanced typographic features. Font handling is difficult in general, and even more so in web browsers. We’d prefer to depend on open source font code if possible because we can patch it quickly and participate in improving it.

We enabled OpenGL accelerated layer composition. This stage in the rendering pipeline is where we composite independently-rendered regions of a web page for your screen. Accelerating it helps us most when resizing images and video. GPUs are much better at performing those sorts of transformations than CPUs. For more information, see this post from Joe Drew. We hope to accelerate the rest of our rendering pipeline on Mac OS X soon.

We also added support for the Cocoa NPAPI event model and the Core Animation NPAPI drawing model. These specifications are a big step forward for browser plugins on Mac OS X. They are easier to develop for, properly documented, and designed with IPC in mind. As of version 10.1, Adobe’s Flash plugin supports Cocoa NPAPI. Which leads me to the next improvement…

Firefox 4 will run many plugins out-of-process on Mac OS X. All of your plugins will be out-of-process if you’re running the x86_64 version of Firefox. If you’re running the i386 version of Firefox we’ll run some popular plugins, such as Flash 10.1+, out-of-process but others will run in-process for performance and user experience reasons. And yes – the x86_64 version of Firefox will be able to use i386 plugins.

Those are the major Mac OS X-specific changes but we’ve also made a large number of minor improvements for Mac OS X. Combined with all of the great cross-platform improvements like our new JavaScript engine, WebM, and better HTML5 support, Firefox 4 should take the web to a whole new level for our users.

About these ads

About Josh Aas

Josh Aas is a Gecko platform software engineer with Mozilla Corporation.
This entry was posted in Mozilla, Programming. Bookmark the permalink.

35 Responses to Firefox 4 for Mac OS X: Under the Hood

  1. Lion says:

    http://www.apple.com/macosx/lion/

    What are Mozilla’s plans for supporting Firefox 4.0 or later versions on OSX 10.7 Lion? Guess it will be x86_64 also as the default on 10.7?

  2. Mark says:

    I’ve got a Macbook Pro which is about 3 years old (iirc) and has a NVIDIA GeForce 9400M card. But I’m getting only 2 fps on the spinning images demo/test so I’m pretty sure it’s either not flipped on or not working properly. I spoke with someone else on a Mac (with older hardware) and they report the same thing.
    I checked under Troubleshooting Info > GPU Accelerated Windows, and it reads “3/3 OpenGL” which I’m told means all three of my open windows are being accelerated, but clearly something is wrong.
    Know the story on this?

  3. nemo says:

    Hey Mark, are you sure you’re on b7 or a nightly, and not b6?

  4. Paul Biggar says:

    I thought we didn’t support i386 on 10.6? Did that change?

  5. Evan says:

    “we’ve switched from a ppc/i386 universal binary to an i386/x86_64 universal binary.”

    Does that mean end of the road for PowerPC? I always thought “universal binary” means PPC + Intel?

  6. GMX says:

    Pardon my ignorance, but how does one switch architectures on an Intel Macbook (OS 10.6.4)? This is more out of curiosity, I’m of course happy to run it in x86_64 mode.

    Also, how do you run 32-bit plugins on the 64-bit Firefox? I’d always read that it can’t load the 32-bit plugins such as Flash Player, and in fact, when I moved from 4.0b6 to 4.0b7 the Flash Player stopped working. I installed their experimental 64-bit Player (“Square”) to get it working again, but I’d rather go back to running their release code again if possible.

    Thanks!

    • Josh Aas says:

      Firefox 4 for Mac OS X in x86_64 mode can load some i386 plugins, but not all. It can only load plugins that use the Cocoa version of NPAPI, any i386 plugin still using Carbon NPAPI won’t load. I suspect you had a version of Flash 10.0 installed, which uses Carbon NPAPI, and that is why it wouldn’t load. Flash 10.1+ uses Cocoa NPAPI and should load just fine.

      Your build must also be an i386/x86_64 universal binary in order for plugin/host architecture mixing to work. Since our official builds are i386/x86_64 universal binaries you’d have to be using an unofficial single-architecture build in order for this to be a problem.

      Finally, the hidden preference “dom.ipc.plugins.enabled.x86_64″ must be set to true in “about:config”. It is true by default, so if you didn’t mess with the hidden IPC preferences then this won’t be a problem.

      • GMX says:

        Thanks Josh.

        I am not sure which version of Flash I had installed earlier (prior to reinstalling with “Square”). However, I just uninstalled Square and installed Flash 10.1 from a fresh download and once again Flash is not working, just a black screen area where the video content should be.

        This is using the official Firefox 4.0b7 binary downloaded from Mozilla.

        dom.ipc.plugins.enabled.x86_64 is set to “true” (default) so there should be an issue there. Any idea why this might not be working?

        FWIW, about:plugins lists the following:

        Version: 10.1.102.64
        Shockwave Flash 10.1 r102

    • BenE says:

      To get Flash streams (like YouTube) to run on OS X 10.6.4 using Firefox 4 beta 7, I had to go to the Get info for FF and ENABLE 32-bit mode.

      • jhz says:

        Same problem with Flash not running (OSX 10.6.5), and same solution works : using Get info to instruct FF 4 ß7 to start in 32-bit mode.
        I’d rather have it run in 64-bit, but in the meantime…

    • mike says:

      So what’s mozillas response to this? Work in 32-bit mode and use the stable flash version? but that breaks the 1Password integration for me on my macbook pro. or install the 64-bit experimental flash? I’d like to hear a word on this.

  7. Allan says:

    Sounds very great!

    But I like to ask you why firefox does not use the built-in sandbox feature for applications in OS X? Seems like a no brainer to me.

    Thanks for the wonderful software!

  8. Rik says:

    Nice summary and of course very welcome improvements.

    When you say 540% better on the MS Psychadelic Browsing Demo, what are the raw numbers we can expect? On my 2 months old 13″ MBP, I’m seeing around 40fps and I remember I had about the same fps on an older MBP this summer before WebGL was activated.

    • Mark says:

      Rik:
      I tried it out and only got 37. (I’ve a new-ish MBP.)
      As I intimated further up in the comments, I think there is a bug or problem that many Macs are not being accelerated properly.

    • Josh Aas says:

      Raw numbers aren’t useful because the numbers are highly dependent on your exact environment (software and hardware), including the size of the browser window you’re testing in. To give you an idea of the degree to which this is true, a 200×200 window can generate scores of around 1300 on MS Psychedelic Browsing on my fast Mac Pro. Make the window 800×900 on the same machine and the score is around 35. A smaller window size could easily allow a machine to generate a much higher score than a significantly faster machine.

      The only useful number is the percentage difference from comparisons in an identical environment, which is what I posted.

      • Rik says:

        Thanks Josh, that’s exactly the kind of information I expected. Seeing the 540% improvements and still getting a very low number, I thought I was missing on something.

  9. Peter Abrahamsen says:

    This sounds like a great improvement for performance, but how about the UI? The fact that my menubar clears out during a javascript alert tells me something is deeply wrong with something behind the scenes.

  10. David Baron says:

    How does something get 540% faster? If something gets 100% faster then it takes no time at all, so >100% faster, by the usual definition of % faster, isn’t possible.

  11. Deepak says:

    Is Firefox 4 going to integrate with Mac keychain for storing passwords? I’d prefer not to use 3rd party plug-ins.

  12. Skoua says:

    Sounds good, felt like FF4 was not an update very interesing for mac users but I was wrong.

    Not really related but do you guys plan to fix the Photoshop space bar bug when running FF soon?
    I experience this bug each time I use a FF beta (3.0, 3.6, 4.0…)

    Thanks for your great work.

  13. Tester says:

    The MagicMouse in combination with Firefox 4beta7 & Flash 10 isn’t usable. Why is the scrolling-performance not good as in FF3 ? You are talking about “performance-improvements”, but I can’t see & feel this in FF4beta7.

  14. mike says:

    Posted this some days ago but received no response so far, so I’m reposting this at the bottom of the thread:

    So what’s mozillas response to this? Work in 32-bit mode and use the stable flash version? but that breaks the 1Password integration for me on my macbook pro. or install the 64-bit experimental flash? I’d like to hear a word on this.

  15. Sherry says:

    My issue is my MacBook Pro about three years old, up to date will not two finger expand font or content. It did prior to updating Firefox. It works in Safari. Any suggestions or advise?

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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