Clutter on Android: first results

With the release of Android 2.3, there’s a decent way to integrate native applications with the NativeActivity class, an EGL library, and some C API to expose events, main loop, etc. So? how about porting Clutter to it now that it looks actually feasible? After a few days of work, the first results are there, quite promising!

There’s still a fairly large number of items in my TODO before being happy with the state of this work, the most prominent items are:

  • Get a clean up pass done to have something upstreamable, this includes finishing the event integration (it receives events but not yet forward them to Clutter),
  • Come up with a plan to manage the application life cycle and handle the case when Android destroys the EGL surface that you were using (probably by having the app save a state, and properly tear down Clutter).,
  • While you probably have the droid font installed in /system/fonts, this is not part of the advertised NDK interface. The safest choice is to embed the font you want to use with your application. Unfortunately fontconfig + freetype + pango + compressed assets in your Android package don’t work really well together. Maybe solve it at the Pango level with a custom “direct” fontmap implementation that would let you register fonts from files easily?
  • What to do with text entries? show soft keyboard? Mx or Clutter problem? what happens to the GL surface in that case?
  • Better test the GMainLoop/ALooper main loop integration (esp. adding and removing file descriptors),
  • All the libraries that Clutter depends on are linked into a big .so (which is the Android NDK application). It results in a big .so (~5 MB, ~1.7 MB compressed in the .apk). That size can be dramatically reduced, sometimes at the expense of changes that will break the current API/ABI, but hell, you’ll be statically linking anyway,
  • Provide “prebuilt libraries”, ie. pre-compiled libraries that makes it easy to just use Clutter to build applications.

18 thoughts on “Clutter on Android: first results

  1. marwee

    Hi!

    Your clutter port looks very nice. But i didn’t found the source in the git-repositories. Would you release it?

    Greetings
    marwee

  2. damien Post author

    Hey, I haven’t touched the port since that post. However I have a talk at the Desktop Summit in a week and I do intend to have a “preview” release for people to play with. Stay tuned!

  3. damien Post author

    @Patrick: For now, it’s NDK only. It’s possible to make it work from the Java side, it’s quite a lot of work though.

  4. Vishal

    Hi,

    I have downloaded your code , and tried that to create .so file using ndk-build command but it is failed to build.
    As it is not finding clutter modules in NDK , how i need to provide clutter modules to it.

  5. sduclos

    sduclos :
    @Vishal
    do this:
    export NDK_MODULE_PATH=/clutter-android-prebuilts
    you can test with:
    $ cd /cogl-1.9.2/example/android/hello
    $ /ndk-build

    @sduclos
    @Vishal
    do this:

    export NDK_MODULE_PATH=\/clutter-android-prebuilts

    you can test with:

    $ cd \/cogl-1.9.2/example/android/hello
    $ \/ndk-build

  6. Vishal

    @sduclos

    Hi sduclos ,

    I have tried your above way but still the code is jni is not compiling i am getting some errors and it is not compiling..

  7. sduclos

    @Vishal
    Sorry to be late,

    clutter-android-prebuilts is already compiled

    To compile ‘hello’ in cogl source tree ‘cd’ to it and run ‘ndk-build’

    You need to set NDK_MODULE_PATH to the path of clutter-android-prebuilts before
    running the build.

    You should get a .so in libs/

  8. diega

    Hi Damien,
    Great work! I would like to test it and eventually contribute with some lines. Could you make it available for download?

    Thanks a lot!

  9. diega

    Well I find the ohand sample from your git repo. Now, as @Vishal pointed it’s complaining about missing NDK_MODULE_PATH. So, how did I get my own clutter-android-prebuilt? How can I compile clutter so I can provide ndk-build with the missing module? @diega

  10. diega

    Hey!
    finally got it working :) sorry for the comments flood (u can remove the old ones if u want).
    The funny thing is that it loads the app nice in my ICS Tablet but it doesn’t animate :) I just see the Hand static in the middle.

  11. damien Post author

    @diega w00t! you’re probably the second person in the world to have that working :) Having the hand static is the intended behaviour for http://git.lespiau.name/cgit/ohand. Be aware that the prebuilt binaries provided were ultra alpha quality, using OpenGL ES1. It will fall appart if you try to use it.

    A good way to carry on this project today would be to:
    1/ build cogl with https://github.com/rib/cogl-android-sdk (the cogl part of my work here has been upstreamed and then made to work again by Robert Bragg)
    2/ port the clutter patches to 1.10 https://github.com/dlespiau/clutter/commits/android
    3/ debug the result

  12. Ivan

    Hi Damien.

    First off, thanks a lot for this post – without it, I’d be much more hesitant to start what I’m starting now with Clutter on Android.

    I’d like to build Clutter myself, using a standalone toolchain. I’m going to build each of its dependencies one by one for different API levels, ABIs and with/without NEON. Did you go through a similar process to get your results? Any blockers/traps I should prepare to?

    Also, what do you know about building/running Clutter on iOS?

  13. guofeng.routon

    Hello,I want to know how to make “Maybe solve it at the Pango level with a custom “direct” fontmap implementation that would let you register fonts from files easily” work.I have try to start this work ,but it is slowly Can you give me some suggestions?Thank you very much!!!

  14. Doreen

    I see you share interesting stuff here, you can earn some additional
    money, your website has big potential, for the monetizing
    method, just search in google – K2 advices how to monetize a website

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>