Saturday, November 20, 2010

Blue Skies v1.15

  - Bug Fix: Moon image not showing up on some handsets
  - Update: Stars twinkle more
  - Update: Balloons light better

The moon thing is actually a bit odd, let's discuss that.  Basically, if you dig back in the archives far enough, you'll find a post about Android incorrectly premultiplying PNG files.  What I did to work around that was implement a loader for TGA images, which generally works well.  As a bonus I got support in for greyscale luminance textures that way as well, which has definitely saved some memory here and there.

Now, since TGA isn't a native Android image format, the program that builds the APK package compresses it to save space, like when you're making a ZIP file.  The standard formats of PNG and JPG don't get this compression, since they're compressed already and it's a waste.

Once you have a compressed file in your APK, what happens later on is you open the file and attempt to read it.  The system transparently decompresses it into memory to allow this, so you yourself don't need to deal with the compression at all.  You read the file and close it, the systems throws away the temporary decompressed version, and all is well.

The wrinkle is that this temporary buffer it puts things into has a size limit, of around 512k.  If the file in question is bigger than that, it'll just fail to open and you're out of luck.  That's what happened here, the uncompressed TGA file for the moon was bigger than 512k, so the file didn't open, so my TextureManager class just returned an empty white image.  Now the question is, how did I manage to miss this?  Don't I ever test anything?

Well, that's the trick.  Some of the manufacturers raise this limit.  I know Motorola and HTC do -- to what, I'm not sure.  I've run into this before, and I know to pay attention to it, but since I was testing primarily on an HTC Incredible, it worked just fine and I forgot to double-check it.  It worked on a Droid 2 as well.  It does not, however, work on something like a G2 or a Nexus One that's running stock Android.

So what can you do to work around this?  Annoyingly, the Eclipse ADK doesn't support any way to tell a file to store uncompressed.  If you write an ANT script or something you can do that, but the Eclipse build process won't let you.  However, if you want to work around THAT, you can change the filename extension to something like JPG, and the Eclipse build process will automatically skip compressing it, and you can make your file as big as you like.  I mean, hey, the Android resource process doesn't use extensions anyway, right?

So, to summarize:  Careful about non-native file sizes in your package files, if it's larger than half a meg you might run into trouble.

EDIT:  It looks like the 'assets' folder can be used for the purpose of non-compressed files, which somehow or other I missed the last time I was researching this.  I'll have to try this next go-round.

Friday, November 19, 2010

Blue Skies v1.1

  - New Feature: Stars at night
  - Bug Fix: Flickering clouds

I thought I had the flickering issue fixed with an adjustment to my sorting function, but I was wrong.  As it turned out, the sorting has been fine all along.  Here's what the bug actually was.

Basically, the clouds move towards the camera.  As they get close they alpha out, and once they pass a certain point they teleport back to their distant starting position.  This gets us the infinite-supply-of-clouds look.

Cool, except that when I moved them back to the start I was moving them explicitly to CLOUD_START_Y.  Since their movement is time-adjusted based on the framerate, they'd gradually drift relative to the other clouds as fractions of a value got knocked off.  Eventually, you'd end up with two clouds really close to each other, and then you'd get a framerate hitch or something, and have two clouds get teleported within the same frame.

Once that happens, those two clouds end up sitting in the exact same spot forever, effectively.  The sorting code would work its way through the list, and occasionally slight rounding errors would result in them being sorted in a different order, then back again a bit later.  This is where the flickering look came from.  This also explains why I never saw the problem yesterday -- I was restarting the wallpaper periodically as I tested things, and it takes quite a while to manifest, somewhere around 20-30 minutes.

The fix for all this is to calculate CLOUD_START_Y - CLOUD_VANISH_Y and subtract that value from the cloud's existing Y origin.  This means everything stays spaced the same relative to each other, and the flickering doesn't occur.

While doing this, I added stars that fade in during the night, since I got that as a comment.  :)

Thursday, November 18, 2010

Blue Skies v1.05

  - New Feature: Time of Day cycling
  - New Feature: Sun and Moon
  - Bug Fix: Flickering clouds

Since the first thing people always ask for is time of day shifting, here it is!  This one was kind of tricky to get looking good, as it's fairly fill-rate expensive already so I'm trying to avoid blending from one background to another and do everything with color tinting.  In the process I added a moving sun and moon that key off the time of day as well.  The sun is always there, and the moon only shows up if you have time of day enabled.

The occasional cloud flickering you might have seen was due a bug in my sorting code, it should be smoothed out now.

EDIT:  I tell a lie, the flickering still happens.  Amazing, I didn't see it the entire time I was testing the time of day stuff, then see it happen right after I publish the update.  I guess that's tomorrow's task.

Wednesday, November 17, 2010

Lots of Updates for the HowTo Activity

We get a lot of e-mail from folks confused about how to use the wallpaper they just downloaded, and while several of these have the open button set up with a popup that takes you to the live wallpaper chooser, several of the products are still missing this.

I'd like to get this to be consistent, so in the name of pulling the band-aid right off, we'll be pushing a number of updates over the next couple of days to make our handling of this consistent.  Sorry for any inconvenience, folks!

Tuesday, November 16, 2010

NA Flags Free

As it's been a slow seller for quite a while, I just put a free version of NA Flags up on the market.  It's an attractive wallpaper with really nice animation, in my opinion, but it doesn't show well in a static screenshot -- I'm hoping a free version being available will help get folks to check it out.

Aquarium v2.2

  - Update: Old default background is available again
  - Update: Two new fish!
  - Bug Fix: Fish shouldn't get stuck refusing to eat

Nothing huge here, but the 'fish not eating' but was not obvious to reproduce, read a few posts down for an explanation.  :)