Monday, November 9, 2015

J2ME Images stop loading mystery

In our app we need to be able to show images from EPUB files on J2ME .. and those images change as the user goes from page to page.  We're using the rather neat LWUIT HTMLComponent to render the HTML pages with some custom additions to handle media (published here on GitHub).

Mysteriously using a Nokia 206 phone we could load about 19 900x900 pixel jpegs (showing one after the other; with a garbage collect System.gc() call in between) before it would give up - and any subsequent request to load an image would throw an IOException.  This was being caused by an IOException being thrown inside the ResourceThread as it was trying to load the image.  This of course was happening only on the devices: not on the emulator.

J2ME phones is that they vary widely in resolution and memory - from a Nokia 110 which has a 120 pixel or so wide screen to an Asha which has 240x320.  Perhaps images can simply be bounded to a maximum of 320x320 ; or perhaps we need to have different epub files for different phones.  Not sure of that yet.

Note to anyone (still) working with J2ME to avoid tearing hair out : keep images as small as they can be.

No comments:

Post a Comment