Phil Hassey - game dev blog
Phil Hassey as Rambo
".. I've been there,
I know what it's like,
and I'll do it again if I have to."

Android Day 9: Taming the G1

The G1 is the baseline Android phone. I found that users who tested with one of them were getting low framerates and crashes. Since the G1-level-devices are about 20% of the market, I wanted to be able to support them. Here’s the journey I took:

Step 1: Getting and activating a G1

Getting one was relatively easy. They are no longer produced, but I found a good one on eBay and with shipping and everything it was only $137 to get it. Activating was another matter altogether. The phone is locked so that you have to sign into your Google Account upon startup to activate the phone in order to get to the Home screen. After reading numerous tips on the internet, the way I was able to activate it was by borrowing a friend’s SIM for a few minutes to activate my phone. Then I put a dummy SIM back into mine and things worked fine.

Step 2: Fixing crashes

As I’ve found, the event loop and the graphics loop are in two separate Java VM’s on the phone. Some tweaks I had added to get it working on the Nexus One / Droid were not working on the G1. Again, global variable hacks coming back to haunt me. I adjusted some of my hacks and it seems to be working on the G1 now, so I’ll have to re-test on the Nexus One / Droid later. The lesson here, again, is avoid using globals in C if you can, because a lot of how the whole Android setup is makes it a real pain.

Step 3: Graphics performance improvements

The graphics were going at about 2 FPS. Which was not acceptable. I did a lot of investigating and I found that this one thing got me from like 2 FPS to an acceptable (though not blazing) 15 FPS or so. I changed my bitmaps from their default format to ARGB_4444. I do this during my load_texture method:

Bitmap bitmap = BitmapFactory.decodeStream(stream).copy(Bitmap.Config.ARGB_4444,false);

That was all it took! However, I’d like to have it be ARGB_8888 on higher-end phones if possible. I’ll see if I can figure out a way to do that. It’s a bit of a tough call, because on the Droid the 4444 improves the framerate, but if you look closely you can see a difference from the 8888.

One way would be to detect the SDK version, however, I hear rumors that older devices might be getting an update to 2.x. So that wouldn’t be foolproof either. I think I’ll be sticking with 4444 for now. It improves the framerate on most devices and the visual change is pretty minor in the larger scheme of things.

Step 4: Removing warnings about “call to OpenGL ES API with no current context”

These warnings are just annoying. Basically they happen anytime you do a gl call when you aren’t within your rendering method. It took some hunting but I found a few calls that were doing this in my Pause pop-up screen. This was simply a job of decrufting my code a bit. (I had OpenGL code that was from the very first version of Galcon for the iPhone that was being called in code that isn’t supposed to have any rendering in it anymore.)

I think I’m getting pretty close to releasing this game. I’m going to run this build by the testers again and see how they like it. I hope to launch soon!


9 Responses to “Android Day 9: Taming the G1”

  1. Zaph Says:

    You can always add an option for 4444 textures in the settings, because there will always be a phone you haven’t tested 🙂
    Then just set it by default on first run to the value you think it should be (based on SDK or something)

  2. digdog22 Says:

    Are the Palm WebOS and eventually Android versions of Galcon playable against other operating systems with online multiplayer, such as iPhone OS?

  3. philhassey Says:

    Yes, all mobile versions of Galcon can play against eachother 🙂


  4. digdog22 Says:

    That’s… flipping… AWESOME!!!

  5. Alex Says:

    Why not just test the speed of a few ARGB_888 ops, if they are fast enough, use that.

  6. Deozaan Says:

    Yeah, you can’t just detect the SDK version to solve the graphics issue. I’ve got my G1 running Android 2.2 via a custom ROM called CyanogenMod.

    Congrats on getting it up on the market!

  7. null Says:

    Same here, running Cyanogen version of Froyo. I think a lot of people have this installed now, since the G1 has been pretty much abandoned by HTC when it comes to official updates.

  8. philhassey Says:

    Yeah, sounds like just leaving it at 4444 was probably the right decision then.


  9. Little Big Tomatoes » Blog Archive » Porting Galcon to Android Says:

    […] Android Day 9: Taming the G1 […]