Porting Firefox To Apple Silicon: Tales From The Trenches

For any smaller and larger software product that aims to be compatible with Apple’s MacOS, the recent introduction of its ARM-based Apple Silicon processors and MacBooks to go with them came as a bit of a shock. Suddenly one of the major desktop platforms was going to shift processor architectures, and with it likely abandon and change a number of APIs. Over at Mozilla HQ, they assumed that based on past experiences, Apple’s announcement of ‘first Apple Silicon hardware’ would also mean that those systems would be available for sale.

Indeed, one week after the November 10th announcement Apple did in fact do so. By then, Mozilla had worked to ensure that the Firefox codebase could be built for Apple Silicon-based MacOS. Fortunately, through the experiences of running Firefox on Windows-on-ARM, they already had gained a codebase that was compatible with 64-bit ARM. Ultimately, the biggest snag here was the immature Rust language and dependency support for Apple Silicon, which set back the first release.

When it came to the distributing of Firefox on Intel- and ARM-based Macs, the decision was made to package both versions of the application into a so-called Universal Binary. While this pads out the size of the installer, it also means easier distribution and would not affect the built-in updater in Firefox. This also allowed for an easy fix for the Google Widevine DRM module, for which no Apple Silicon version was available at first, allowing the same module for Intel to be used with either Firefox version via the Rosetta 2 binary translator in MacOS (as we covered previously).

After this it was more or less smooth sailing, with some Rosetta 2-based glitches and MacOS Big Sur-related bugs that spoiled some of the fun. What this experience shows is that porting even a big codebase like Firefox to Apple’s new platform is fairly straightforward, with lack of support from toolchains and other dependencies the most likely things that may trip one up.

The Rosetta 2 feature, while helpful, also comes with its share of gotchas as the Firefox developers found out, and of course there is a lot more optimization that can (and should) be done for such a new platform.

16 thoughts on “Porting Firefox To Apple Silicon: Tales From The Trenches

  1. Apple Silicon coming as a shock shouldn’t have to anyone with a finger even slightly on the pulse.

    Those of us on the MAME team were well-prepared for the release of Apple’s transition to ARM, and MAME amounts to a project driven by a load of hobbyists, with exactly zero funding from anyone.

    Wil some performance-related concessions had to be made – we don’t have a JIT backend that can emit AArch64 machine code, for example, just x86 or x64 – the vast majority of the emulator works perfectly fine on Apple Silicon-based machines.

    This isn’t out of any sort of pre-planning, or out of any sort of magic, or even out of any sort of special design methodology. It’s all pretty straightforward. Develop with a language with wide support across modern platforms (C++17), keep 3rd-party dependencies up-to-date, and use a toolchain that is forward-looking rather than stuck in some idealistic concept that isn’t borne out in practice.

  2. I’d suggest that optimisation for such a platform is not a SHOULD be done at all. There is no point using up valuable and limited time optimising for just one odd hardware platform, unless it makes up a vastly disproportionate volume of users.

    So games on consoles it makes sense to optimise, huge numbers buy the game on console.. For a web browser on apple silicon, I expect there is lots but its probably not anything like the same percentage.

    1. Software companies count $$$ when it comes to adding features, not # of customers. Corporate clients will pay big bucks for support while the gamers are broke teenagers in mom’s basement.

      1. There is definitely some truth in that, but the average age (and wealth? (I’d assume)) of gamers is continually going up as the folks who were kids/ computer gaming youths in the 80’s etc are all now getting on a bit, but still into computer gaming – unlike their parents/grandparents, many of whom should they still be living are probably technologically averse – There’s a big shift underway as folks who grew up and are comfortable with computer/gaming/electronics outnumber those that don’t comprehend how the magic boxes works at all well (If my own relatives are anything to go by at least).

        I rather expect such optimising will be done in this case – but not just because of corporations – Mozilla will need to provide a good performant platform on apple silicon, which is likely to be a growing segment of the market anyway for there own market share. I was just pointing out there isn’t a SHOULD clause by default – and that quite possibly for now the best use of man hours isn’t optimising for apple silicone, but multi-arch and arch agnostic things in general.

      2. “..while the gamers are broke teenagers in mom’s basement.”

        2/3 of gamers are aged 18-54, according to a 2020 Statista study. Regardless, I eagerly await your next installment, wherein you go on about how the kids these days spend too much time on their dingety-danged phones and are always blasting the rocky-roll music.

  3. Apple is an interesting company. Developing a desktop ARM CPU and and accompanying macOS is no small feat. At the same time they managed to fuck up Reminders completely by “reinventing” it and making it not backwards compatible. I guess not all engineering teams at Apple are equally competent.

      1. Apparently it’s “censorship” when a property owner cleans graffiti from their walls!

        And isn’t it amusing how people are all into laissez–faire capitalism until their web site gets shut down, at which point they become sociaiists and demand that the government force people to do business.

        1. Mozilla has no business deciding what is an isn’t graffiti on your screen or my screen when none of those belong to Mozilla. If they want to make it their business thats their own suicide note.

      2. Please just stop with your negativity. Remain civil and don’t put people into categories. If you speak of social issues, remember to be kind in the first place, if you really want to improve anything.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.