Make sure scene graph state not changed after xnode.udateGeometricState()

I’ve got this weird behavior where everything works fine 10 times out of 11. Once in a while I get the above message.



Sometimes that message refers to rootNode, other times to galaxyNode.



The way I set things up is there’s a rootNode where all other nodes are attached to. galaxyNode is that node containing all the stars in the Galaxy View.



Note that the crash ONLY happens during the initial creation of the world. If the whole thing went smoothly, that thing doesn’t rear its ugly head. At least it hasn’t up to now.



With that said, I’m wondering what I should ensure to do to make sure that doesn’t happen. I know that if modifications are done outside LWJGL’s thread, it has to be put inside a Future (and it is). To the best of my knowledge a “node”.updateGeometricState() doesn’t have to be done each and every time something is added to that node, but it has to be done before the “return this;” of the Future. Right?



So, what should I especially be looking for to find the problem? Am I wrong about the “updateGeometricState()”? Is there some order I have to follow when manipulating nodes? And last, in one of the method that is encapsulated in a Future, there a lot of calls to other methods inside it. Could that pose a problem?



scratch head



Thanks in advance.

This can only happen when the scene is changed after uodategeometric. Since that cannot be in a normal update loop and its not deterministic I most definitely think you still have a threading problem.

I agree. But It’s pretty hard to find the cause. I wish I could be able to trace it back to the exact point but it can’t be done (if it is, I have no idea how to do so). So in a nutshell, that’s why I was asking.



I thought using Future would guarantee a “safe run”. But I guess it doesn’t. I checked many times the code and nothing modifies the nodes outside the Future.



I will try to dig deeper. I’m just not sure how I can effectively hunt that bug down.

The error message tells you which Spatial causes the problem, maybe you can check where you modify that.

I did.



Mostly it says rootNode, less often galaxyNode. And as I said, I call methods inside that Future that call other methods. That’s why it’s pretty hard to get to the root of the problem.



Trying to simplify…

The building thread (in GameLogic.java) is the one that calls the Future. But I wanted to reuse the code so I added what is normally done by the LWJGL thread in the Future.:

[java]

void pinStarsFuture(final int treeNodeID) {

Future futPinStars = getGame().enqueue(new Callable<Object>() {



@Override

public Object call() {

pinStars(treeNodeID);

setStarsCounter(treeNodeID);

currentNode = treeNodeID;

galaxyNode.updateGeometricState();

getRootNode().updateGeometricState();

return this;

}

});

try {

futPinStars.get();

} catch (InterruptedException ex) {

Logger.getLogger(GameLogic.class.getName()).log(Level.SEVERE, null, ex);

} catch (ExecutionException ex) {

Logger.getLogger(GameLogic.class.getName()).log(Level.SEVERE, null, ex);

}

}

[/java]



When the game has loaded a new galaxy and everything is running, the JLWGL calls pinStars(node) (and the other methods) when the ship switch to a different Octree Node and doesn’t need the Future. But the GameLogic thread do need the Future when building the galaxy at start, so I encapsulated the methods in a Future. The code is the same.



I haven’t had a single crash while the game was running (galaxy generated and LWJGL doing the node switching methods). Who knows, maybe I was lucky… :?:

I think I might have found the problem. An out-of-order updateGeometric call… :confused: I started the game 25 times and not a single crash. Hopefully that takes care of the problem for good.



I do seem to have another issue though, but this one doesn’t crash the game. Judge by yourself from these pictures:







It is very rare, but the ship is mis-constructed? As soon as I move the ship everything goes back to normal though. What could do that?