Firefox Focus with GeckoView

Firefox Focus is private browsing as an app: It automatically blocks ads and trackers, so you can surf the web in peace. When you’re done, a single tap completely erases your history, cookies, and other local data.

Protecting you from invasive tracking is part of Mozilla’s non-profit mission, and Focus’s built-in tracking protection helps keep you safe. It also makes websites load faster!

A screenshot of Firefox Focus, showing the main menu open with the heading "26 Trackers Blocked"

With Focus, you don’t have to worry about your browsing history coming back to haunt you in retargeted ads on other websites.

Bringing Gecko to Focus

In the next weeks, we’ll release a new version of Focus for Android, and for the first time, Focus will come bundled with Gecko, the browser engine that powers Firefox Quantum. This is a major architectural change, so while every copy of Focus will include Gecko—hence the larger download size—we plan on enabling it gradually to ensure a smooth transition. You can help us test Gecko in Focus today by installing the Focus Beta.

Diagram of Firefox Focus 7, showing how the app now contains GeckoView, instead of just relying on the WebView component provided by Android

Note: At time of publishing, Focus Beta is conducting an A/B test between the old and new engines. Look for “Gecko/62.0” in your User-Agent String to determine if your copy is using Gecko or not.

Up until this point, Focus has been powered exclusively by Android’s built-in WebView. This made sense for initial development, since WebView was already on every Android device, but we quickly ran into limitations. Foremost, it isn’t designed for building browsers. Despite being based on Chromium, WebView only supports a subset of web standards, as Google expects app developers to use native Android APIs, and not the Web, for advanced functionality. Instead, we’d prefer if apps had access to the entirety of the open, standards-based web platform.

In Focus’s case, we can only build next-generation privacy features if we have deep access to the browser internals, and that means we need our own engine. We need Gecko. Fortunately, Firefox for Android already uses Gecko, just not in a way that’s easy to reuse in other applications. That’s where GeckoView comes in.

GeckoView: Making Gecko Reusable

GeckoView is Gecko packaged as a reusable Android library. We’ve worked to decouple the engine itself from its user interface, and made it easy to embed in other applications. Thanks to GeckoView’s clean architecture, our initial benchmarks of the new Focus show a median page load improvement of 20% compared to Firefox for Android, making GeckoView our fastest version of Gecko on Android yet.

Screenshot of the GeckoView AAR (Android Library) file. It is about 37 MB large.

We first put GeckoView into production last year, powering both Progressive Web Apps (PWAs) and Custom Tabs in Firefox for Android. These minimal, self-contained features were good initial projects, but with Focus we’re going much further. Focus will be our first time using GeckoView to completely power an existing, successful, and standalone product.

We’re also using GeckoView in entirely new products like Firefox Reality, a browser designed exclusively for virtual and augmented reality headsets. We’ll be sharing more about it later this year.

Building Browsers with Android Components

To build a web browser, you need more than just an engine. You also need common functionality like tabs, auto-complete, search suggestions, and so on. To avoid unnecessary duplication of effort, we’ve also created Android Components, a collection of independent, ready-to-use libraries for building browsers and browser-like applications on Android.

For Mozilla, GeckoView means we can leverage all of our Firefox expertise in building more compelling, safe, and robust online experiences, while Android Components ensures that we can continue experimenting with new projects (like Focus and Firefox Reality) without reinventing wheels. In many ways, these projects set the stage for the next generation of the Firefox family of browsers on Android.

For Android developers, GeckoView means control. It’s a production-grade engine with a stable and expansive API, usable either on its own or through Android Components. Because GeckoView is a self-contained library, you don’t have to compile it yourself. Furthermore, powering your app with GeckoView gives you a specific web engine version you can work with. Compare that to WebView, which tends to have quite a bit of variance between versions depending on the OS and Chrome version available on the device. With GeckoView, you always know what you’re getting — and you benefit from Gecko’s excellent, cross-platform support for web standards.

Get Involved

We’re really excited about what GeckoView means for the future of browsers on Android, and we’d love for you to get involved:

Let us know what you think of GeckoView and the new Focus in the comments below!

About Dan Callahan

Engineer with Mozilla Developer Relations, former Mozilla Persona developer.

More articles by Dan Callahan…

About Andreas Bovens

More articles by Andreas Bovens…


10 comments

  1. PhistucK

    First, congratulations on GeckoView.

    > Because GeckoView is a self-contained library, you don’t have to compile it yourself, nor do you need to worry about Android updates changing things out from under your app.

    Yeah, applications could use an old GeckoView version without worrying about the security of the user. Yeah… That makes sense. Updates are bad, after all. Vulnerabilities are good. Yes.
    (Alternatively, GeckoView will never have vulnerabilities)

    (Did I convey the ridiculousness of that paragraph accurately enough or is more needed?)

    With power, comes a ton of responsibility that many developers refuse to acknowledge.
    You should make sure it is super easy and painless to update (but that can never be true, because humans create bugs :().

    September 13th, 2018 at 11:03

    Reply

    1. Dan Callahan

      That’s a fair point; we should reword that paragraph.

      With GeckoView, it’s possible for developers to ensure that their apps are always using a recent, known version of a modern engine. With WebView, you have to work with whatever the user’s phone happens to have, even if it’s not been updated in a long time. That can add a fair bit of complexity, introduce security risks, or cause bugs that are difficult to reproduce.

      GeckoView avoids that, but developers have to keep their apps’ dependencies up to date. As they should anyways. :)

      We’re doing our best to ensure that GeckoView presents a well-encapsulated, stable API across versions, so that updates are as easy and painless as possible.

      September 13th, 2018 at 14:03

      Reply

      1. Colin Lee

        I work at Mozilla with GeckoView and it’s great that we can innovate with a new engine. I’m proud that we’re able to bring this out in our browsers and also make it available for independent developers.

        Let’s please be careful about the claims we make though. Webview has not been built-in to Android in a non-upgradeable way since Lollipop. That’s long enough that phones without an upgradeable Webview aren’t supported by modern apps. Webview receives separate updates from the OS itself on the Google Play store as new Webview (Android L-M) and Chrome browser (Android N+) versions are released.

        September 13th, 2018 at 18:39

        Reply

  2. Jens

    > Thanks to GeckoView’s clean architecture, our initial benchmarks of the new Focus show a median page load improvement of 20% compared to Firefox for Android, making GeckoView our fastest version of Gecko on Android yet.

    You guess the question ;) How does GeckoView compare to Android’s WebView – or how does GeckoView based Focus compare to the former WebView based Focus? It’s ok if it’s worse (and will be improved), but not given any numbers just tell me it must be really worse…

    September 13th, 2018 at 11:07

    Reply

    1. Dan Callahan

      To be completely honest, we’re still working on getting reliable measurements across engines (this is surprisingly tricky!).

      Quantitatively, it may be a bit of a mixed bag at first due to the differences between the engines, but we’re committed to being competitive with WebView.

      Subjectively, I haven’t had any issues with performance using both versions of Focus side-by-side over the past two months.

      September 13th, 2018 at 14:32

      Reply

  3. Christopher Anthony

    GeckoView still has problems rendering Google search correctly. Looks like Google search from the 80’s. I have reported this in the past Firefox Focus nightly forum but referenced a Firefox nightly where a fix was being tested. Hopefully fixed soon in fi and in Focus.

    September 13th, 2018 at 13:57

    Reply

    1. Dan Callahan

      Unfortunately, Google itself serves a degraded experience to Firefox and Gecko-based browsers on mobile. We’re hopeful this will change in the future.

      September 13th, 2018 at 14:10

      Reply

      1. Nav

        Is there any evidence of this? This sounds like a horribly anti-competitive practice.

        September 13th, 2018 at 14:16

        Reply

        1. Dan Callahan

          User-Agent sniffing on google.com has been a known thing for at least the past five years: https://bugzil.la/975444

          We’ve got some options here, but more generally speaking, this is why projects like GeckoView and Firefox for Android are so critically important to the health of the Web. Having many competing engines keeps everyone honest: the only way to ensure compatibility is through coding to the standards. Without that competition, the Web dies.

          September 13th, 2018 at 14:53

          Reply

    2. Andreas Bovens

      Try it again today. Google Search should look much better now.

      September 17th, 2018 at 04:35

      Reply

Post Your Comment