[SOLVED] Nifty Crashing app

My app is random crashing for no reason apparently because of nifty , this is the error :

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
at de.lessvoid.nifty.screen.Screen.forwardMouseEventToLayers(Screen.java:352)
at de.lessvoid.nifty.screen.Screen.mouseEvent(Screen.java:339)
at de.lessvoid.nifty.Nifty.forwardMouseEventToScreen(Nifty.java:308)
at de.lessvoid.nifty.Nifty.access$1600(Nifty.java:77)
at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processEvent(Nifty.java:1373)
at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processMouseEvent(Nifty.java:1329)
at com.jme3.niftygui.InputSystemJme.handleMouseEvent(InputSystemJme.java:169)
at com.jme3.niftygui.InputSystemJme.onMouseButtonEventQueued(InputSystemJme.java:232)
at com.jme3.niftygui.InputSystemJme.forwardEvents(InputSystemJme.java:296)
at de.lessvoid.nifty.Nifty.update(Nifty.java:288)
at com.jme3.niftygui.InputSystemJme.endInput(InputSystemJme.java:113)
at com.jme3.input.InputManager.processQueue(InputManager.java:819)
at com.jme3.input.InputManager.update(InputManager.java:883)
at com.jme3.app.Application.update(Application.java:604)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)

Do anyone else get this error and know now to fix it ?

I just found out that this problem maybe some kind of thread sync problem between nifty and jm.
It starts to happen after I moved this code from the appinit to the appupdate ( using custom flag to run it just once )

    ref_niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);

It seens if this is executed after the jm3 thread is already running it may get this error and crash…
I moved it back into the appinit, it seens to have fixed the problem…

I could be wrong but I am sure that someone said that you have to init nifty in the startup. If not, you get this error message. Because of this special behavior it’s also not possible to exit() and init nifty during runtime (to “clean” nifty for example).

Are run on the same thread.

As Mordag said, you need to initialize nifty at the beginning otherwise you can run into problems with incomplete setup. I have an AppState that I initialize at the beginning that handles nifty and any specials calls I need to make to it.

I’ve never run into a circumstance where I’ve had to “clean” nifty even with restarting game states.

Thats it, If its in the appinit it fix the problem.
Thanks for the confirmation guys !