Last post I gave a run-down of some of the performance issues I ran into with Cordova/Canvas on Android. While I’m sure newer hardware would probably have no problem, since my poor phone is ancient and, obviously, I’m stuck with it until I get a new one, I decided to give the ol’ LibGDX a try.
Luckily, unlike my cell lines, Java code doesn’t go bad if left unattended for a few months, so a little configuring and adding libraries and I was off to the races deploying to the android emulator. And…2fps. Better than cordova, and there’s quite a bit more going on, but still, that’s obviously unacceptable. It was a little better on my phone, but not by much. Undeterred, I spent most of my spare time during the Thanksgiving holiday optimizing and trying various things to squeeze a few more fps out.
I learned some valuable things, like how to trace processes on Android, etc, and I learned a few valuable lessons:
1. If something didn’t change since the last frame, don’t update it!
2. That goes doubly for the map. Seriously.
3. LibGDX’s stage2d is a little slow, so I used it sparingly (ie: only for the UI). To be fair, most of my improvements were due to not updating things every frame.
4. (Edit: added this) Also, changing all the texturefilters from Linear,Linear to Nearest,Nearest helped a lot (probably can go to MipMapLinearNearest for the min filter).
With all that, I’m up to ~20fps on the emulator and ~50fps on my phone, which is much better, to say the least.
I’m now working on cleaning up the UI to be (a) more awesome and (b) look better on the variety of screen sizes. Right now, being a debug build, I’m mostly focused on making sure everything is readable/touchable on small devices. Hopefully I’ll have an apk ready for people to try in a week or two.
Download the latest build!