Saturday, May 21, 2016

KStars Lite comes to Android

Let's start this post by watching two videos :) I have finally got KStars Lite working on Android.

Sorry for bad quality, but it seems to be everything my old smartphone is capable of.
And here comes the corresponding screen video! (Don't forget to set 720p)

As you can see there are a lot of things to do - pinch to zoom right now works as scrolling with wheel, so I need to tweak it a bit. Interface will be changed completely and right now it is just my proposal prototype. Loading of files seems to take more time than on my laptop, but I'm happy to see that with asteroids and comets it still performs well on tablet (need to try it on other devices).

And now I will tell you a small story about what has been done since the previous my post and how did I compile Android version:

  1. All nodes that are responsible for drawing graphics are now reparented to the class RootNode (later there may be used its subclasses for the same purpose). RootNode handles QSGTexture generation for stars and also clipping. The problem with clipping was that in QtQuick Scene Graph you can't draw ellipse as OpenGL draws everything in triangles. To do it I found C++ triangulation algorithm implementation specifically tailored for QQuickItem, but it was designed to handle all kinds of polygons so it required a lot of resources and made SkyMapLite really slow. Later I found much simpler solution: choose some corner (in the case of ellipse any its point) and create a triangle from this point to the next 2 points. Simple but works perfectly.
  2. Added asteroids and comets. To do it I changed the structure of nodes a bit. So now there are 2 types of SkyNodes - PlanetNode and PointSourceNode. Both of them reflect to SkyPainter's functions drawPlanet and drawPointSource. For all objects in PlanetItem and some of the objects in AsteroidsComet PlanetNode is used, while CometsItem uses only PointSourceNode to draw comets as stars. After adding asteroids and comets performance didn't fall down. I even tried to draw all of them as bright stars without any checkings on magnitude/zoom level and everything worked well.
  3. Android build - well, that is a long story :) Initially I thought about it as something easy to do and haven't even included to my tentative timeline in proposal, but I was totally wrong. First there was a problem with KF5 dependencies because less than a half of KF5 modules are available for Android.
    My mentor, Jasem Mutlaq, made a great thing and got rid of KIO dependency, without which I was able to compile Android version. Even after that it didn't work and I got only a black screen. I spent a lot of time trying to setup debugger as you can't debug CMake project for Android from Qt Creator. The only feedback from my tablet that I am able to get now is looking at log output (which seems to be sufficient as all major errors are there).
    After spending a plenty of time on searching for a cause of black screen, I found out that "include(KDECompilerSettings NO_POLICY_SCOPE)" in top CMakeLists.txt file seems to cause the error. Without it everything worked fine, but still I had to tackle a few minor bugs before I was able to see SkyMapLite on my tablet.
    I also started to work on pinch to zoom as you can see from my video. 
You will find instructions on how to compile KStars Lite for Android in my next post (which will be published tomorrow I hope). For now, I will run Android build in various Android emulators to see whether it works fine everywhere and then I will port PlanetMoons to KStars Lite. Stay tuned!


  1. Nice work! Once you're ready for production make sure you contact the KDE-Android[1] mailing list for it to be in the kde play store account[2]