StandardGame don't terminate

Hi everybody,



I ported my SimpleGame application to StandardGame. I have this problem that the application halts when I hit ESC and the program don't terminate.



Infact, if I try the code under heading "Creating our StandardGame" (from http://www.jmonkeyengine.com/wiki/doku.php?id=simplegame_to_standardgame&s=gametaskqueue) it has the same effect.



What could be wrong since pure example code does the same? Even if I add a keyhandler and call System.exit(0) in the example program, it does not terminate. (I can see that System.exit(0) is actually called.)


Weird, does this exit?:



void exitTest(int n){
     if(n = 50) System.exit(0);
     System.out.println(n);
     exitTest(n+1);
}



Silly, yes.. but sometimes its good to start with basics ;)

sampie said:

Infact, if I try the code under heading "Creating our StandardGame" (from http://www.jmonkeyengine.com/wiki/doku.php?id=simplegame_to_standardgame&s=gametaskqueue) it has the same effect.

What could be wrong since pure example code does the same? Even if I add a keyhandler and call System.exit(0) in the example program, it does not terminate. (I can see that System.exit(0) is actually called.)


The code you linked to does not attach a controller, which would be a good spot for the exit call.  What OS are you on.. have you tried using another key?

Hi,



>Weird, does this exit?:



>void exitTest(int n){

>     if(n == 50) System.exit(0);

>     System.out.println(n);

>     exitTest(n+1);

>}



Yes, this program, as a such, does exit. (But if I add this code to StandardGame key handler, it does not exit)



>The code you linked to does not attach a controller, which would be a good spot for the exit call.  What OS are you on… >have you tried using another key?



After I realized that the StandardGame ESC hangs the game, I added following key controller (but it hangs too):



      GameControlManager gcm=new GameControlManager();

        GameControl exitControl=gcm.addControl("exit");

        exitControl.addBinding(new KeyboardBinding(KeyInput.KEY_A));



    ActionChangeController quit = new ActionChangeController(exitControl, new ControlChangeListener() {

public void changed(GameControl control, float oldValue, float newValue, float time) {

if (newValue == 1.0f) {

//game.shutdown();

System.out.println("A key controller");

System.exit(0);

}

}

    });

    gameState.getRootNode().addController(quit);



I am running on Ubuntu Linux 9.10. If this is an Ubuntu bug, I will report it to them. I have also tried to switch from OpenJDK -> SunJDK, but that did not help.



Any suggestions, what I could try next?



Perhaps this is some kind of a thread related issue as StandardGame is using threads?



A strange thing too is that rendering using StandardGame seems to take a lot more processor time than the SimpleGame, which I converted from.

sampie said:

I am running on Ubuntu Linux 9.10. If this is an Ubuntu bug, I will report it to them. I have also tried to switch from OpenJDK -> SunJDK, but that did not help.

Any suggestions, what I could try next?

Perhaps this is some kind of a thread related issue as StandardGame is using threads?

A strange thing too is that rendering using StandardGame seems to take a lot more processor time than the SimpleGame, which I converted from.


AFAIK, it should that key binding work under Ubuntu 9.10 (I'm using ESC for exit in my own project), though I've never tried it out explicitly.  If you want to zip and post your code, I'd be happy to give it a test spin on my end

Hi,



>AFAIK, it should that key binding work under Ubuntu 9.10 (I'm using ESC for exit in my own project), though I've >never tried it out explicitly.  If you want to zip and post your code, I'd be happy to give it a test spin on my end



I just wrote this simple example of a StandardGame, which hangs for me (even if this A -key handling is taken away).



I think it should be tried at least 5 times and at each run at least 5 seconds should be waited until pressing ESC or A. For some reason, if I reboot my machine, this code sometimes exit properly for a couple of times at first and then starts to hang consistently.



import com.jme.bounding.BoundingSphere;

import com.jme.input.KeyInput;

import com.jme.input.controls.GameControl;

import com.jme.input.controls.GameControlManager;

import com.jme.input.controls.binding.KeyboardBinding;

import com.jme.input.controls.controller.ActionChangeController;

import com.jme.input.controls.controller.ControlChangeListener;

import com.jme.math.Vector3f;

import com.jme.scene.shape.Box;

import com.jmex.editors.swing.settings.GameSettingsPanel;

import com.jmex.game.StandardGame;

import com.jmex.game.state.DebugGameState;

import com.jmex.game.state.GameStateManager;





public class MyJmeTest

{



void simpleTest() {

StandardGame game = new StandardGame("A Simple Test");

// Show settings screen

try {

GameSettingsPanel.prompt(game.getSettings());

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

game.start();



DebugGameState state = new DebugGameState();



        GameControlManager gcm=new GameControlManager();

        GameControl exitControl=gcm.addControl("exit");

        exitControl.addBinding(new KeyboardBinding(KeyInput.KEY_A));



    ActionChangeController quit = new ActionChangeController(exitControl, new ControlChangeListener() {

public void changed(GameControl control, float oldValue, float newValue, float time) {

if (newValue == 1.0f) {

//game.shutdown();

System.out.println("A key controller");

System.exit(0);

}

}

    });

    state.getRootNode().addController(quit);



Box box = new Box("my box", new Vector3f(0, 0, 0), 2, 2, 2);

box.setModelBound(new BoundingSphere());

box.updateModelBound();



box.updateRenderState();

state.getRootNode().attachChild(box);

state.getRootNode().updateRenderState();



GameStateManager.getInstance().attachChild(state);

state.setActive(true);



}



public static void main(String[] args) {

MyJmeTest app = new MyJmeTest();

app.simpleTest();

}

}

This is propably an ubuntu bug as also other OpenGL game (OpenArena) experience the same exit hang when the example code is run a couple of times. I was able to reproduce the hang with 3 different ubuntu machines.