Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Hello folks,
I'd like to share with you a few things that I did during this Xmas.
Besides the fact I'll never ever take a vacation before Xmas, because Brasov is
a tourist attraction and it was FULL of tourists in that period. I could ski
only once :( , because it snowed just a few days before New Year and then
the police closed the roads to the ski resort because there were way too many cars
in that area.
Anyway it was also great because I spent a lot of time with my family. But because there was no snow outside, I also had some time for myself and I didn't want to waste it all. So, for the sake of old times, I started to buy some old games (from gog.com) and I began to play them with my son.
But we soon finished most of them and we started to play 0 A.D. a super cool and free (as in freedom and also as in beer) strategy game. After a while my son asked me if he can play that game on a tablet. I said: "at this moment you can't play it, but I'll take a look :) ". This is how my new journey began, and this is what this article is about :) .
Strangely, exactly five years ago I began another journey, on the same day I started the Qt on Android port ;-).
So, I began to check the source code and I posted my intention on wildfiregame's forum and then, I started the 0 A.D. game engine port:
So, the big question is: Are there any decent OpenGL debuggers/tracers for
Android?
A quick search on the net answered my question. It seems there are a few OpenGL
debuggers/tracers for Android. So, I started to check if any of them are decent
and useful :) .
So, I started to check the apitrace (retrace) source code to see how and if it can be
ported on Android. The challenge was to pass the application arguments and to
redirect somehow the stdout and stderr from the device to the desktop.
Apitrace (retrace) uses stdout, stderr to send back results to the user/UI.
So, the only way to do it, it was to hook stdout and stderr on Android and redirect all the traffic to a pair of sockets, then forward those sockets (using adb) to the desktop. I also chose to use stdout socket to send the params to application on device. But what if the application doesn't have INTERNET permission set, which is needed for sockets? What if those ports are already in use? This was an easy task, because I asked myself the same question a few months ago, when I worked on Android 5.0 support, so I chose to use LocalServerSocket instead of the old fashioned sockets. This way all the potential problems were avoided.
So, I created an android GLES retrace on the C++ side (based on egl_x11), a custom Android Activity, a custom Surface, etc. Of course, I also added QtCreator support (yeah more qmake projects :D ), to be able to debug, and soon, I had a working Android retracer!
I could use it via telnet with just a few steps (I'm listing those steps because they can be used to debug the connection):
adb forward tcp:1234 localabstract:apitrace.github.io.eglretrace.stdout
adb forward tcp:1235 localabstract:apitrace.github.io.eglretrace.stderr
telnet 127.0.0.1 1235
telnet 127.0.0.1 1234
-d /sdcard/0ad/appdata/logs/pyrogenesis.trace
But, as you can see, is not very easy to use and I couldn't use the UI ...
Again, my titanic laziness come into place, and I began to work on a decent way to do retrace on Android using the existing UI.
IMHO a decent retracing on Android needs to meet the following requirements:
Folks, I'm proud to let you know that I managed to finish all those requirements!
I'm quite pleased how it ended up! All the mysterious errors were revealed!
Of course because I want all the people to enjoy a decent Android OpenGL debugging, I created the pull request for all my work.
Using apitrace on Android I knew which OpenGL commands caused the errors! This helped an 0 A.D. developer, (Philip` is his nickname on irc), to fix these errors in a few minutes. I needed his help because my OpenGL skills are close to 0 (A.D.) and making an Android retracer didn't make me smarter at all in that area :).
Of course this is the first step to get 0 A.D. on Android, there is a lot of work to be done before we'll be able to enjoy it on our tablets!
If anyone wants to join this fantastic free project, please check 0 A.D.'s participate page. 0 A.D. is a project where anyone can help not only programmers! If you are an artist that knows how to paint, create music, write scenarios, have a nice voice, etc., or you want to help with translations for the game, in your own language, you can join and contribute!
Also apitrace needs contributors, if you want to help, then you can check their TODO list to see if you can make the world a better place ;-) !
My apitrace repo is here and the pull request here.
My 0 A.D. repo is here and the patches here and here you have info about how to compile 0 A.D. on Android.
About KDAB
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.
5 Comments
22 - Jan - 2015
Lorenzo
Hi BogDan,
very interesting review of the Android graphics tools landscape.
I am the product manager for the ARM Mali GPU tools, including the graphics debugger, and I would like to support you getting the debugger to work. I am sorry to hear your experience with the tool was unsuccessful, we are doing our best to support all the different configurations of Android.
What device are you using, and do you have some more information on the crash you experienced? We are aware of a bug that happens with some particular devices, and we are working on a patch release. Please feel free to answer here, or via email, or even open a support request on our community website.
Thanks, Lorenzo
23 - Jan - 2015
BogDan Vatra
Hi Lorenzo,
I used Nexus 10 with Android 5.0. . I tried your latest SDK available in Dec. 2014 and I followed the non-root steps from help. The symptoms I already described.
If you want to test/fix MGD at the end of the blog you have some links which will give you enough information about how to compile, run & debug 0 A.D. yourself.
Just to be crystal clear: This blog is not about apitrace vs xxxxxx tools. This article is about the power, the beauty and the magic of free (as in freedom) software ;-) .
23 - Jan - 2015
Sys
Congratulations for improving the Android and Qt development!
26 - Jan - 2015
Juergen
Thanks Bogda. Nice job as usaual. One question, have you considered Vogl as OpenGL debugging tool? http://en.wikipedia.org/wiki/VOGL
26 - Jan - 2015
BogDan Vatra
I did, but sadly VOGL developers didn't considered GLES :) . And it was much easier to add Android retrace support to apitrace than to add GLES support to VOGL ;-) .