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 Replies to “GeckoView: Embedding Gecko in your Android Application”

  1. 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 ?

  2. 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!

  3. 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!!

  4. 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?

  5. 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!

  6. @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.

  7. @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.

  8. Nice work and promising alternative to the horrible WebView,

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

  9. 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?

Comments are closed.