Some JME questions


I noticed that if the render thread stops because of an error, or if you press the close button of my game, the thread that handles sending/recieving of multiplayer messages keeps running. This doesn’t prevent you from connecting again, but it’s a useless thing which uses some of your CPU and ram.Is there a way to mark that thread as deamon, so that it will stop as soon as the render thread stops.

It would also be useful if I control what happens if the player presses the close button (for a popup to ask if you are sure that you want to close, and to terminate multiplayer propperly etc.)

What I also noticed is that during multiplayer, when I’m the only one online, It works well, but when other players join, I sometimes get an error, and the strange part abouth the error is that I have not written any of the classes that appear in the stack trace, those are all internal JME classes and internal java classes. Is there a way to fix this error? It seems to be physics-related, because the stack trace starts with some bullet classes.

A simular bug in my game as the above one: nifty gui sometimes fails to handle a mouse event when I click the login button. When I use tab to select the button, than press enter or space, it doesn’t happen. simular to the above, it only happens at random times, and the stack trace doesn’t go trough any of my classes.

I really hope you can give some more information about this.

Many thanks in advance.

I think more context (and things like stack traces) are going to be needed before anyone can really reply in detail to your questions…

Override Application.close() or destroy() to shut down stuff when the app lifecycle ends.

1 Like

Yeah, what normen says.

The client’s write thread is not daemon because I wanted to give it the best chance to get a complete message out. So you have to shut down networking specifically when the app closes… and normen’s “override destroy” approach is the safest.

Also acceptable is to use an AppState’s cleanup method… if you are already using app states to manage your code.

Thanks abouth the destroy method. It works.

I’m now going to try to do the glitch again, and I’l copy and paste the stack trace here.

I got a stack trace of someone else who was playing my game:

[java]miku:dist julien$ java -jar MyGame.jar -Xmx2048M -Xms2048M

Sending login request…

Login sucessful.

Inventory geladen.

Bezig met initialiseren…


Bezig met laden…

(0.77662337, 0.8999989, 1.3271077)

(0.92662334, 0.8999989, 1.1771077)

(0.13636361, 0.0, -0.13636361)



Cinematics initialized

23 juil. 2012 19:39:39 handleError

GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]


at de.lessvoid.nifty.elements.Element.canHandleInteraction(

at de.lessvoid.nifty.elements.Element.mouseEvent(

at de.lessvoid.nifty.screen.MouseOverHandler.processMouseEvent(

at de.lessvoid.nifty.screen.Screen.forwardMouseEventToLayers(

at de.lessvoid.nifty.screen.Screen.mouseEvent(

at de.lessvoid.nifty.Nifty.forwardMouseEventToScreen(

at de.lessvoid.nifty.Nifty.update(

at com.jme3.niftygui.InputSystemJme.endInput(

at com.jme3.input.InputManager.processQueue(

at com.jme3.input.InputManager.update(



at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(



miku:dist julien$[/java]

I haven’t touched any of the classes listed in the stack trace, and this error happened at a random time.

Do you ever make any changes to the scene graph or nifty screens from a thread under than the render thread?

Having said that, that stack trace looks familiar. I seem to remember getting something similar when I had malformed nifty screens. Try trimming your screens down to the bare minimum and then add things a bit at a time to see what causes the exception.

an other question, when the openGL window loses focus, the game freezes. Is there a way to stop this from happening? I tried looking trough everything of the appsettings, but I didn’t find anything to stop this.

@beniboy said:
an other question, when the openGL window loses focus, the game freezes. Is there a way to stop this from happening? I tried looking trough everything of the appsettings, but I didn't find anything to stop this.

You mean the app pauses when it loses focus?

That worked, thanks