Hello!
I am trying to load a alpha-less image on Corona, and it fails in some specific devices only.
Unfortunately for me, the devices are exactly the most popular ones in my target markets (developing nations), so I need to make it work on them.
I submitted a bug report, and got a reply:
We can only reproduce this issue on a Nexus One (Android 2.3) device.
The following low-end Android devices displayed the image without issue:
- Droid (1st generation) running Android 2.2
- HTC Evo 4g running Android 2.2
- Galaxy SII running Android 2.3
- Kindle Fire (1st generation) running Android 2.3
- Nook Color running Android 2.2
What I’ve noticed is that our Try/Catch block is failing to catch that OutOfMemory exception just on that one device. I’ve never seen this happen before, because we do successfully catch these errors and implement fallback mechanisms on other devices. In fact, we have a lot of code in place to predict how much memory is available, and if we do not have enough, then we down-sample the loaded image (skipping every other pixel) to make it fit in memory. We also down-sample the image if it is larger than OpenGL’s max texture size. Now, if we still get an OutOfMemory exception (because some devices lie about how much memory is available), then we force garbage collection, reduce color quality from 32-bit to 16-bit (reducing the memory footprint in half), and then attempt to load the image one more time. If we still fail to load the image from there, then we have no choice but to return “nil” in Lua.
But… since Java is failing to catch this OutOfMemory exception for your particular device, then unfortunately my only advise to you is to exclude support for the device this is happening to you in the app store, which you can do via the Google Play Developer Console.
Regards,
Joshua Quick
Mind you, the issue also happen on my device (Xperia Play with Android 2.3) and on many devices that are simple copies of the reference device (ie: Nexus One is a reference device, many manufacturers of cheap devices just copy it and use its implementation of Android).
So, if Joshua Quick is correct, Corona can load 16-bit images, so how I do that myself on my own? I don’t need those images to be 32-bit at all (even on devices that can load them at 32-bit).
Also, although I asked that by e-mail noone replied so far, CoronaLabs intend to fix their bug of not detecting the exception in those devices? (it outright crashes when the image is right on the start of the program, but LogCat does capture the exception, but when I load the image following my game flow, it throws a unhandled exception window instead of crashing).
And I would also like to know if I can load half-resolution image on my own too, avoiding duplicating assets and code (the images are imagesheet) that will only be used one the problematic devices.