BitmapFont

Hey all…

Another BitmapFont issue on Android, same one that has been reported prior to this. The only difference is (or at least possible difference)…

I’m not getting the error:

  • Running in debug mode
  • Running the application the 1st time right after install (both signed & unsigned)

I am getting the error:

  • Every time I run the app after the initial install.

The stacktrack is the same as from this thread:

http://hub.jmonkeyengine.org/forum/topic/nifty-on-android-is-broken-again/

Any help in tracking down the cause would be greatly appreciated.

Little bit more info about this:

It only happens with the installed APK if USB debugging is enabled on the device.

I know this isn’t a critical problem by any stretch, as it’s the odd case where this will be an issue, but if there is a way of resolving it, that would be really cool.

Hopefully the debug mode being enabled will give someone a clue as to what is causes the problem when loading bitmap fonts.

I wonder if it has something to do with the way BitmapFontLoader accesses the material definition. It does it like so:

[java]
MaterialDef spriteMat = (MaterialDef) assetManager.loadAsset(new AssetKey(“Common/MatDefs/Misc/Unshaded.j3md”));
Material mat = new Material(spriteMat);
[/java]

When, in most cases, (at least I do it this way):

[java]
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
[/java]

Is it possible that the asset key isn’t translated the same due to the debug mode being enabled?

I think this was fixed in head but not in trunk maybe. The issue is/was with how the loader reads the files and it seems that when there is a line feed on the last line then (on android) a null line is returned. The old code used available() to see if there was more stream to read which is an improper use of available().

1 Like

Erm… I may have spoken too soon. The problem is intermittent.

@pspeed said: I think this was fixed in head but not in trunk maybe. The issue is/was with how the loader reads the files and it seems that when there is a line feed on the last line then (on android) a null line is returned. The old code used available() to see if there was more stream to read which is an improper use of available().

Oh cool… Ok! This is good news. I’m gonna go take a look at how this is being done now.

Thanks so much!

It was ready() that it was using before:
http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core-plugins/com/jme3/font/plugins/BitmapFontLoader.java

And indeed the fix was never ported to the 3.0.x branch:
http://code.google.com/p/jmonkeyengine/source/browse/branches/3.0final/engine/src/core-plugins/com/jme3/font/plugins/BitmapFontLoader.java

1 Like
@pspeed said: It was ready() that it was using before: http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core-plugins/com/jme3/font/plugins/BitmapFontLoader.java

And indeed the fix was never ported to the 3.0.x branch:
Google Code Archive - Long-term storage for Google Code Project Hosting.

Yep yep! That fixed the issue.

Thanks so much for pointing this out!