Very rare crash when closing game

It is very rare, but it happens. It’s not a huge issue since it’s when the app is closed and it’s only the InputManager removing mappings, but I would prefer is it wasn’t there, obviously. :slight_smile:

Stack trace:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] java.lang.NullPointerException at com.jme3.input.InputManager.deleteMapping(InputManager.java:610) at com.jme3.input.FlyByCamera.unregisterInput(FlyByCamera.java:292) at com.jme3.app.FlyCamAppState.cleanup(FlyCamAppState.java:90) at com.jme3.app.state.AppStateManager.cleanup(AppStateManager.java:297) at com.jme3.app.Application.destroy(Application.java:635) at com.madjack.games.disenthral.Disenthral.destroy(Disenthral.java:244) at com.jme3.system.lwjgl.LwjglAbstractDisplay.deinitInThread(LwjglAbstractDisplay.java:196) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:233) at java.lang.Thread.run(Thread.java:722)

[java]
// method where it happens
public void deleteMapping(String mappingName) {
Mapping mapping = mappings.remove(mappingName);
if (mapping == null) {
throw new IllegalArgumentException("Cannot find mapping: " + mappingName);
}

    ArrayList triggers = mapping.triggers;
    for (int i = triggers.size() - 1; i >= 0; i--) {
        int hash = triggers.get(i);
        ArrayList maps = bindings.get(hash);
        maps.remove(mapping); // line 610 is RIGHT HERE.
        // For some reason the map retrieved from the hash is null.
    }
}

[/java]

PS: For some reason the “This is a support topic” is checked and can’t be unchecked… :confused:

Nobody ever got that error? Not that it would make a difference. Curious though.

I’ve never seen the error. Do you by any chance delete the mapping twice or something?

As far as I know there shouldn’t be any deletion or removal at this point. Could it be that the order which things are destroyed could be different once in a while? I know, it’s just a wild stab in the dark…

The fact that it seldom occurs makes me think to a threading issue, but idk if your app is multi threaded. is It?

When destroy() is called all my threads have been terminated.

This happens inside super.destroy().

I might add that all my bindings are in an AbtractAppState. That’s why I was suggesting above some things might get destroyed before others. App states might be before input manager?

@madjack said: I might add that all my bindings are in an AbtractAppState. That's why I was suggesting above some things might get destroyed before others. App states might be before input manager?

Yeah, app states should always be destroyed before InputManager.

Looking at the stack trace again, it’s related to fly cam… do you use flycam? Do you remap it’s controls at all?

Note: I’m just fact finding. It’s a bug in the engine but I’m trying to narrow it down.

Okay. Why didn’t I see it was pertaining to the fly cam… I don’t know. Maybe I should read with my eyes next time. :facepalm:

I don’t use the flyCam nope, but I don’t remove its state, just use setEnabled(false) in simpleInitApp().

@madjack said: Okay. Why didn't I see it was pertaining to the fly cam... I don't know. Maybe I should read with my eyes next time. :facepalm:

I don’t use the flyCam nope, but I don’t remove its state, just use setEnabled(false) in simpleInitApp().

Ah… fly cam is poorly behaved in a lot of cases.

I still think this NPE is a bug but you can work past it by removing the fly cam state.

Yeah. I’ll remove the state. I’ve never removed the state that because that part of the code was done while the flyCam wasn’t an app state. Yes, it’s been that long. XD

I’ll repost if I ever get that error again, but considering I had it maybe twice in months… Unlikely.

Just had it happen again. This time I thought about copying the trace. The twist here though is, the flyCam app state IS removed from my game… Happens in DebugKeysAppState. -.-

[java]
Mar 19, 2013 4:52:14 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.jme3.input.InputManager.deleteMapping(InputManager.java:610)
at com.jme3.app.DebugKeysAppState.cleanup(DebugKeysAppState.java:87)
at com.jme3.app.state.AppStateManager.cleanup(AppStateManager.java:297)
at com.jme3.app.Application.destroy(Application.java:635)
at com.madjack.games.disenthral.Disenthral.destroy(Disenthral.java:236)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.deinitInThread(LwjglAbstractDisplay.java:196)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:233)
at java.lang.Thread.run(Thread.java:722)
[/java]

@madjack said: Just had it happen again. This time I thought about copying the trace. The twist here though is, the flyCam app state IS removed from my game... Happens in DebugKeysAppState. -.-

[java]
Mar 19, 2013 4:52:14 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.jme3.input.InputManager.deleteMapping(InputManager.java:610)
at com.jme3.app.DebugKeysAppState.cleanup(DebugKeysAppState.java:87)
at com.jme3.app.state.AppStateManager.cleanup(AppStateManager.java:297)
at com.jme3.app.Application.destroy(Application.java:635)
at com.madjack.games.disenthral.Disenthral.destroy(Disenthral.java:236)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.deinitInThread(LwjglAbstractDisplay.java:196)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:233)
at java.lang.Thread.run(Thread.java:722)
[/java]

Do you somewhere clear all mappings of the input manager?

If so, why?

A long time ago I wanted to remove all bindings tied into the input manager thinking they would all be removed. But that didn’t quite work.

I thought I had removed this. I’ll take a look and get back to you.

EDIT: Yeah. It’s still there. I’ll comment the line and see if I get the crash again. Considering rate of occurrence… Oh well.
EDIT2: I remember why I left it there now. ESC handling is removed so no closing of the game when hit.

1 Like

Hello,
I am new to jMonkey and am running into the same problem…
[java]Dec 22, 2013 10:04:56 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.NullPointerException
at com.jme3.app.FlyCamAppState.cleanup(FlyCamAppState.java:90)
at com.jme3.app.state.AppStateManager.cleanup(AppStateManager.java:323)
at com.jme3.app.Application.destroy(Application.java:635)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.deinitInThread(LwjglAbstractDisplay.java:196)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:233)
at java.lang.Thread.run(Thread.java:722)

AL lib: (EE) alc_cleanup: 1 device not closed

Exception: java.lang.IllegalStateException thrown from the UncaughtExceptionHandler in thread “LWJGL Renderer Thread”[/java]

I am not sure what is causing it and would really appreciate some help. It is happening every single time I close the program.

@tlf30 said: Hello, I am new to jMonkey and am running into the same problem... [java]Dec 22, 2013 10:04:56 AM com.jme3.app.Application handleError SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main] java.lang.NullPointerException at com.jme3.app.FlyCamAppState.cleanup(FlyCamAppState.java:90) at com.jme3.app.state.AppStateManager.cleanup(AppStateManager.java:323) at com.jme3.app.Application.destroy(Application.java:635) at com.jme3.system.lwjgl.LwjglAbstractDisplay.deinitInThread(LwjglAbstractDisplay.java:196) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:233) at java.lang.Thread.run(Thread.java:722)

AL lib: (EE) alc_cleanup: 1 device not closed

Exception: java.lang.IllegalStateException thrown from the UncaughtExceptionHandler in thread “LWJGL Renderer Thread”[/java]

I am not sure what is causing it and would really appreciate some help. It is happening every single time I close the program.

First, it is not at all the same problem. Not even close.

Second, it seems you do something strange with the FlyCamAppState since that indicates that its internal FlyByCamera has been set to null… but it was not null after initialize() so you must have set it to null somewhere or initialized this FlyCamAppState in some very strange way.

Hard for us to see how, though.

This is what I set for the settings…
[java]
AppSettings as = new AppSettings(false);
as.setVSync(true);
as.setTitle(“Test”);
as.setFrameRate(512);
if (v == 1) {
as.setRenderer(AppSettings.LWJGL_OPENGL1);
}
[/java]
What other code do you need?

@tlf30 said: This is what I set for the settings... [java] AppSettings as = new AppSettings(false); as.setVSync(true); as.setTitle("Test"); as.setFrameRate(512); if (v == 1) { as.setRenderer(AppSettings.LWJGL_OPENGL1); } [/java] What other code do you need?

Well, we’d need to see the code you are using to do something strange to the FlyCamAppState.

Perhaps try putting together a simple test case that illustrates the problem. Then when that works fine you can trace back to figure out what you do differently in your app. In the rare chance that the test case also fails then we’ll have something to work with.

I have not changed or done anything with the FlyCam. Here is my init method that is overridden, it is the only one of the three override methods that I am using. The only other code that modifies the scene is the previously posted one.

[java]@Override
public void simpleInitApp() {
DataHandler.cells = new Node();
DataHandler.players = new Node();
DataHandler.cells.setName(“cellsNode”);
DataHandler.players.setName(“playersNode”);
rootNode.attachChild(DataHandler.cells);
rootNode.attachChild(DataHandler.players);
AmbientLight ambient = new AmbientLight();
ambient.setColor(new ColorRGBA(1f, 1f, 5f, 1f));//Light Blue
rootNode.addLight(ambient);
//buildGUI();
}[/java]

This is a completely new project that really only has a few hours of time working on it so there really is not a lot of code.

The only thing that fixes it is setting
AppSettings as = new AppSettings(false);
TO
AppSettings as = new AppSettings(true);

[java]AppSettings as = new AppSettings(false);
as.setVSync(true);
as.setTitle(“Test”);
as.setFrameRate(512);
if (v == 1) {
as.setRenderer(AppSettings.LWJGL_OPENGL1);
}[/java]