We originally wrote Mercuna with PC and consoles in mind, but recently we got asked about whether Mercuna ran on Android. The enquiry was through an evaluation request, and my initial response was going to be no, it wasn’t something we had ever tried. However, I decided it was first worth looking to see how hard it would be to port Mercuna to Android. Imagine how delighted I was when the answer turned out to be only a few hours, and we could respond to the enquiry with yes, Mercuna works on Android!
When creating Mercuna we decided to go for a tight coupling with the engine, embracing the Unreal plugin architecture and relying on the engine to provide the underlying services. For example while Mercuna has its own profiling macros for measuring performance, they just wrap the Unreal profiler. The major advantage of this is that when running on different platforms Unreal already takes care of 99% of the differences. This has allowed Mercuna to work on Windows, Linux, consoles and now Android with little or no changes.
However, while we’ve integrated tightly with Unreal Engine, we’ve kept the code that uses Unreal very clearly defined. This wasn’t one of our original design goals but was a practice we naturally adopted after having spent several years working on a previous middleware. As a result this means that we should be able to port Mercuna to other engines relatively easily. When we want to integrate with a different engine, we don’t need to go through Mercuna and change all the profiling macros everywhere, we just need to change our marco definition to use the new engine’s profiler.
In order to get Mercuna to run on Android with Unreal there were a few places where we had to make some compile fixes. This tended to be where we had used some of the more advanced C++11 notation or features. The version of the Android compiler installed by Unreal doesn’t support things such as std::is_trivially_default_constructible, so we had to find alternatives. In particular I was a bit sad that we had to replace our pretty new style custom allocator with an old pre-C++11 version.
The biggest change, and one where we still need to do some work, is due to Android running on ARM CPUs, rather than x86. Various computationally intensive parts of Mercuna have been optimised using SSE instructions, which provides a notable speed up. Luckily we had also kept the original non-optimised versions of the functions and by changing a single hash define could enable these instead for the Android build. We now plan to reimplement a version of the optimisations using the ARM NEON instruction set. Therefore at the moment the Android version isn’t quite as quick as the x86 version but it should only be a few days work to fix this.
While we had always intend to support mobile, it was something we were expecting to take more effort and therefore unfortunately would have to come later in our roadmap. However given the increasing growth in the mobile game market, we are very pleased to have been able add support this major platform so easily.
If you are making an Android game and want spaceships and or creatures flying around, then please get in touch!
The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.