Building custom Chromium #1

As an introduction I would like to write about my current task at my current job without spilling any secrets. I am working on an Android client for rather large secure application platform. The project has several levels, but the main idea is that there HTML5 applications at the top. These are run by a custom version of chromium that is linked together with our platform libraries and only communicates with our servers. The whole should be multi-platform, that is why we have clients for the major OSs, and Android is my responsibility.You would think there nothing new in it. Since the existence of WebKit this is becoming a common way to create multi-platform applications. Write the UI in HTML5, the logic in Javascript then run the whole thing with a built-in browser component. The difference with our stuff is that we needed to integrate our library into the lower levels of chromium. For the desktop client we used the CEF project, but that doesn’t exist for Android. Before me they would patch the original chromium source, build it for android and then rename the whole jni-java part of it. But that is a nightmare to maintain so the code was at least 2 years old.

I chose the Crosswalk project, which sounded right, because it supports mobile platforms, and they claimed they keep up with the chromium source changes. The problem with the whole project is that it is designed as a plug-n-play tool. If you download their packages, there are convenient tools to create an android app from the ground up and only write HTML5 stuff. It also integrates really well with Cordova, which is a project designed to support web applications on all platforms with an easy-to-use API. It provides access to platform features (for example GPS, Contacts…) for the HTML5 apps. And although we also use Cordova in our web apps, this was not enough for our needs.

I needed to create an android app that can connect to our API through a JNI bridge and I needed to use custom chromium to display/run our webapps. I could reuse our patchfiles from CEF because both of them built on the chromium source but of course I also needed to patch the crosswalk part of the code and build everything on Android which was done just enough that I could have a slight idea of what to do, but far from complete.

The main problem was to configure every element to use the same toolchain, which meant 5 different configuration: OpenSSL, ICU, Boost, CMAKE, GYP/GN. I almost needed to configure scons as well, but luckily the android client didn’t need that library. Some project needed to standalone-toolchain version of the NDK, other needed the whole stuff. In the end I managed to build everything with GCC and linking it against the LLVM C++ library, which seems like a crazy idea, but chromium somehow worked better with that library and our project compiled better with GCC, so I had to compromise. The only price was patching LLVM library in the NDK itself (llvm-gcc bug), apart from the weeks of trying out different configuration options.

To be continued…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s