GeckoView: Embedding Gecko in your Android Application

Firefox for Android is a great browser, bringing a modern HTML rendering engine to Android 2.2 and newer. One of the things we have been hoping to do for a long time now is make it possible for other Android applications to embed the Gecko rendering engine. Over the last few months we started a side project to make this possible. We call it GeckoView.

As mentioned in the project page, we don’t intend GeckoView to be a drop-in replacement for WebView. Internally, Gecko is very different from Webkit and trying to expose the same features using the same APIs just wouldn’t be scalable or maintainable. That said, we want it to feel Android-ish and you should be comfortable with using it in your applications.

We have started to build GeckoView as part of our nightly Firefox for Android builds. You can find the library ZIPs in our latest nightly FTP folder. We are in the process of improving the APIs used to embed GeckoView. The current API is very basic. Most of that work is happening in these bugs:

  • Bug 880119: Improve the API for GeckoView
  • Bug 880121: Add support for host application interfaces to GeckoView
  • Bug 880123: Add support for content callback interfaces to GeckoView

If you want to start playing around with GeckoView, you can try the demo application I have on Github. It links to some pre-built GeckoView libraries.

We’d love your feedback! We use the Firefox for Android mailing list to discuss status, issues and feedback.

Note: We’re having some Tech Talks at Mozilla’s London office on Monday (Oct 21). One of the topics is GeckoView. If you’re around or in town for Droidcon, please stop by.

13 Comments

  1. Leonard said,

    October 17, 2013 @ 6:10 pm

    How much it cost (in terms of weight) to include GeckoView in an app?

  2. Robert O'Callahan said,

    October 17, 2013 @ 8:52 pm

    Very glad you’re doing this!

  3. Mark Finkle said,

    October 18, 2013 @ 9:26 am

    @Leonard – It won’t be small. A release build of GeckoView could add ~18MB to your app.

  4. mig said,

    October 18, 2013 @ 11:44 am

    I would love to see a tool to migrate an existing web app to a fully fledged Android application embedding the web app into a Gecko view (like phonegap/cordova but without the need to run on the file:// scheme). Any plan to go that direction ?

  5. Anton Gravestam said,

    October 21, 2013 @ 1:31 am

    Great work!
    I’m working with a large hybrid app for language learning. The initial test we’ve made with GeckoView shows greatly improved rendering performance and html5 media API support compared with WebView. Especially on low end devices. Keep up the good work!

  6. RonMen said,

    October 22, 2013 @ 3:01 pm

    Hi Mark,

    nice to see something like GeckoView coming to developers. I was wondering if there are any informations about the supported HTML5 features if using GeckoView. Did one get full Firefox features if using GeckoView and not WebView? Keep up the good work on GeckoView and Firefox!!

  7. Scott Yan said,

    October 23, 2013 @ 8:12 pm

    GeckoView can’t work when phone is horizontal?
    I need the app to be horizontal, so I add this statements to “onCreate”:
    if(getRequestedOrientation()!=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    and this statement will cause the app can’t be started( it opend, and then quit immediately) , if I remove this statement, the app can open normally, and display web page correctly vertically.

    and then , if I rotate my phone to horizontal, the geckoView became a white screen.

    ps: I download the sample project from here :
    https://github.com/mfinkle/geckobrowser

    so why?

  8. Kevin Smets said,

    October 25, 2013 @ 1:23 pm

    Awesome,

    I don’t mind the 18MB bump if that means you can use a modern browser. for Android web apps. To me, the built in Android browser is like the IE of old, but then for mobile devices.

    Working on a hybrid app at the moment and the stock browser is just pitiful, along with the update process on android which is pretty much non-existant make it a royal pain to develop a proper web app for it.

    Already tried the chromium view(s) to improve the app, I’m highly curious what GeckoView can do. By the way, is there a way to load local files which are packaged alongside GeckoView? It looks like it’s a packaged browser from the screens but I can be mistaken, will need to fiddle.

    Thanks a whole lot for doing this!

  9. Erhannis said,

    October 25, 2013 @ 7:24 pm

    THANK GOODNESS. Working with Webkit is HORRIFYING.

  10. Mark Finkle said,

    October 26, 2013 @ 3:30 am

    @Scott – This is a bug in GeckoView. Firefox does the same thing, but we have code in Firefox to manage the config changes ourselves. You could do that in your app too, but we really want to fix this in GeckoView somehow.

    The reason it happens is because Android will destroy the Activity, and GeckoView, on rotation. So GeckoView loses it’s connection to Gecko.

  11. Mark Finkle said,

    October 26, 2013 @ 3:33 am

    @RonMen – Yes, GeckoView should have the same HTML5 support as Firefox. The only reason I can’t say “does have” is we didn’t hook up some of the Android support code up to GeckoView yet, but it is hooked up in Firefox. Things like the Location provider, Network provider and Battery provider – all of which feed into some HTML5 APIs like Geolocation, Network activity and Battery status APIs.

  12. didlich said,

    November 20, 2013 @ 4:59 am

    Nice work and promising alternative to the horrible WebView,

    curious to see the integration in apache cordova to build nice HTML5 WebApps

  13. Sonu Singh said,

    December 1, 2013 @ 5:40 am

    Looks like loading of files packaged with app is not supported!

    mGeckoView.addBrowser(“file:///android_asset/test.html”);

    results in a page not found! page.

    and if

    mGeckoView.addBrowser(“file:///android_res/raw/test.html”);

    is used the application fails completely!

    Is there a way around this or is it something that needs to be implemented in geckoview?

RSS feed for comments on this post