{"id":486,"date":"2010-08-14T10:54:27","date_gmt":"2010-08-14T16:54:27","guid":{"rendered":"http:\/\/www.philhassey.com\/blog\/?p=486"},"modified":"2010-08-14T10:54:27","modified_gmt":"2010-08-14T16:54:27","slug":"android-day-9-taming-the-g1","status":"publish","type":"post","link":"https:\/\/www.philhassey.com\/blog\/2010\/08\/14\/android-day-9-taming-the-g1\/","title":{"rendered":"Android Day 9: Taming the G1"},"content":{"rendered":"<p>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 <a href=\"http:\/\/developer.android.com\/resources\/dashboard\/platform-versions.html\">about 20% of the market<\/a>, I wanted to be able to support them.  Here&#8217;s the journey I took:<\/p>\n<p><strong>Step 1: Getting and activating a G1<\/strong><\/p>\n<p>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&#8217;s SIM for a few minutes to activate my phone.  Then I put a dummy SIM back into mine and things worked fine.<\/p>\n<p><strong>Step 2: Fixing crashes<\/strong><\/p>\n<p>As I&#8217;ve found, the event loop and the graphics loop are in two separate Java VM&#8217;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&#8217;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.<\/p>\n<p><strong>Step 3: Graphics performance improvements<\/strong><\/p>\n<p>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:<\/p>\n<pre>Bitmap bitmap = BitmapFactory.decodeStream(stream).copy(Bitmap.Config.ARGB_4444,false);<\/pre>\n<p>That was all it took!  However, I&#8217;d like to have it be ARGB_8888 on higher-end phones if possible.  I&#8217;ll see if I can figure out a way to do that.  It&#8217;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.<\/p>\n<p>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&#8217;t be foolproof either.  I think I&#8217;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.<\/p>\n<p><strong>Step 4: Removing warnings about &#8220;call to OpenGL ES API with no current context&#8221;<\/strong><\/p>\n<p>These warnings are just annoying.  Basically they happen anytime you do a gl call when you aren&#8217;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&#8217;t supposed to have any rendering in it anymore.)<\/p>\n<p>&#8212;<\/p>\n<p>I think I&#8217;m getting pretty close to releasing this game.  I&#8217;m going to run this build by the testers again and see how they like it.  I hope to launch soon!<\/p>\n<p>-Phil<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s the journey I took: Step 1: Getting and activating a G1 Getting one was [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112,20],"tags":[],"class_list":["post-486","post","type-post","status-publish","format-standard","hentry","category-android","category-galcon"],"_links":{"self":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/comments?post=486"}],"version-history":[{"count":6,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/486\/revisions"}],"predecessor-version":[{"id":492,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/486\/revisions\/492"}],"wp:attachment":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/media?parent=486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/categories?post=486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/tags?post=486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}