Nifty on Android is broken, again

Hello, lovely monkeys!

Nifty is gives me the error below. My device is a 1st gen Nexus 7 running android 4.2.2. Is there a place where you suggest I start coding to solve this problem?

D/dalvikvm(24296): GC_FOR_ALLOC freed 0K, 10% free 11294K/12536K, paused 35ms, total 35ms
W/dalvikvm(24296): threadid=12: thread exiting with uncaught exception (group=0x418f0ba8)
E/com.jme3.app.AndroidHarness(24296): SEVERE Exception thrown in Thread[GLThread 2800,5,main]
E/com.jme3.app.AndroidHarness(24296): java.lang.NullPointerException
E/com.jme3.app.AndroidHarness(24296): at com.jme3.font.plugins.BitmapFontLoader.load(BitmapFontLoader.java:63)
E/com.jme3.app.AndroidHarness(24296): at com.jme3.font.plugins.BitmapFontLoader.load(BitmapFontLoader.java:171)
E/com.jme3.app.AndroidHarness(24296): at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:288)
E/com.jme3.app.AndroidHarness(24296): at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:370)
E/com.jme3.app.AndroidHarness(24296): at com.jme3.app.SimpleApplication.loadGuiFont(SimpleApplication.java:179)
E/com.jme3.app.AndroidHarness(24296): at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:187)
E/com.jme3.app.AndroidHarness(24296): at com.jme3.app.AndroidHarness.initialize(AndroidHarness.java:455)
E/com.jme3.app.AndroidHarness(24296): at com.jme3.system.android.OGLESContext.initInThread(OGLESContext.java:229)
E/com.jme3.app.AndroidHarness(24296): at com.jme3.system.android.OGLESContext.onSurfaceCreated(OGLESContext.java:205)
E/com.jme3.app.AndroidHarness(24296): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1501)
E/com.jme3.app.AndroidHarness(24296): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
E/com.jme3.app.AndroidHarness(24296):
D/dalvikvm( 510): GC_EXPLICIT freed 2159K, 24% free 21969K/28848K, paused 99ms+11ms, total 381ms
D/Finsky (13268): [1] 5.onFinished: Installation state replication succeeded.
I/Choreographer( 814): Skipped 74 frames! The application may be doing too much work on its main thread.
D/dalvikvm( 814): GC_CONCURRENT freed 6222K, 26% free 20338K/27216K, paused 7ms+17ms, total 108ms

Why do you say this is a Nifty problem? The stack trace looks as if it is from the stats view font.

I works fine on my pc, and even when I use the default font I get the same error.

But I’ll double check and use the default font everywhere just to make sure. I’ll be back with my answer.

Seems like we hit and @nehon fixed this sort of bug in another one of our loaders and now I don’t remember which one. I actually thought it was the font loader… one of the text-based loaders for sure, though.

It happens when there is a carriage return + line feed at the end of the last line of the file. On android, BufferedReader returns this as an empty string and the font loader doesn’t like blank lines.

Ah, nope… similar but different fix:
http://code.google.com/p/jmonkeyengine/source/detail?r=10923

So, the “bug” is that the font loader doesn’t check for line.length() == 0 at the top of the while loop, I guess. That’s the only case I can think of where the split would return null token. Though it’s also possible that split() is behaving differently on android, I guess. It would be interesting to know what the tokens[] array contained at that point.

…I also wonder why no one else has had this issue despite showing stats in their Android apps. Maybe it’s version specific?

@pspeed I understood your comment. But I don’t know if you offered a solution in this comment. Is it me doing something wrong in my code?

@Pixelapp said: @pspeed I understood your comment. But I don't know if you offered a solution in this comment. Is it me doing something wrong in my code?

No, but somehow the standard default font is being read incorrectly on your android where it somehow works for others. Perhaps it is version specific.

If you want to hack the font file you can just remove the trailing line break.

I have a font called BioDiscTitle.fnt. I deleted the new-line at the end of the text file, but I still got the same problem. @pspeed I think that’s what you wanted me to do.

Can someone give me other suggestion on how to fix this? Also, can someone give me a professional font, that looks similar to Times New Roman that doesn’t give this error so I could use it in the mean time?

I’ll try to fix this problem, but suggestions are welcomed.

The system font in the core engine doesn’t have this issue, you can use it.
Your font may have somehow a blank line somewhere.
That’s strange because I tested to insert blank lines in the system font and it was working on my end…But I guess it’s implementation specific…
Gonna fix this…

The stack trace implies that it was the default gui font that was failing.

mhh true…
wtf again…

@nehon Yes the stack trace if for the default font.

Let me know if I can help.

Whoa! I get the same error even when I’m not using ANY kind of gui. I go straight to the game with no HUD.

@nehon Please wait for me to see what is the actual bug so you don’t have to code for no reason.

I’ll look search for the bug in the next couple of days. Then I’ll be back here.

@pspeed said: The stack trace implies that it was the default gui font that was failing.

Not sure if this is related, but I got a complaint about this as well… it had something to do with charset=“WHATEVER” in one of the two JME default .fnt

Could be completely unrelated, however… just in case. The replacement BitmapFontLoader I use, only swaps out the shader… nothing else.

@t0neg0d Like I said, I stripped naked my program from any TEXT gui. Button guis where still there. And still got the error.

I’ll get back when I pen point the problem, but right now I’m really busy with life thingies.

You know… I never thought to ask what version of JME you are running.

@pspeed I was running the “latest” before, and I got the error. I uninstalled about two days ago to install Capuchin Prime (nice name, guys. lol), and I still get the same error.

@Pixelapp said: @t0neg0d Like I said, I stripped naked my program from any TEXT gui. Button guis where still there. And still got the error.

I’ll get back when I pen point the problem, but right now I’m really busy with life thingies.

This doesn’t stop JME from loading it’s default fonts, though.

EDIT: The stack trace specifically shows what the issue is. BitmapFontLoader is choking on one of the two fonts. I’m willing to bet it is the one that has charset=“XXXX” in it… the other has charset=“”

@t0neg0d I guess I don’t have to do any debugging after all.

@nehon Please, have at it!

For whoever is working on this:

info face=“null” size=17 bold=0 italic=0 charset=“ASCII” unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1

This is the first line in the Default.fnt file

face=“null” can’t be a good thing. However, when I ran into this issue, I replaced charset=“ASCII” with charset="" and the issue went bye bye. Maybe this will help.