Java.util.concurrent is popping exception

Hi,
My game is using nifty and zay-es. When I run the game on PC it works fine but when I run it on android, it takes long to display the very first nifty screen.

  1. Is there any way to display loading screen for the first nifty startScreen so that it doesnt simply display black screen.

After navigating a bit in nifty screens, I eventually move to hudScreen and load the scene graph. Now when the transition happens, it again takes some time to display models and again simply shows the old nifty screen. I try to put a wait screen in there but it does not immediately displays that screen and instead stucks until the scene graph is loaded.

  1. is there any way to display that wait screen

Another way that I tried is using loading screens but its popping a exception ‘Java.illegalStateException: screengraph not properly updated for rendering’.

Here is the code that I’m using

[java] public void startGame(){
System.out.println(“Starting GAME”);
confirmed = false;
de.lessvoid.nifty.elements.Element niftyElement = nifty.getScreen(“hudScreen”).findElementByName(“confirmedStatus”);
niftyElement.getRenderer(TextRenderer.class).setText(“Not Confirmed!!”);

    System.out.println("Hello Hello!!");
    //app.getFlyByCamera().setDragToRotate(false);
    //nifty.gotoScreen("hudScreen");

    load = true;
    // Loading screen
        rgas.reInitialize(time);            
        setProgress(0.25f , "Loading: 25%");
        //update(2000);
    //try {
      //  Thread.sleep(500);
    //}
    //catch (Exception e) {
    //}
        //setProgress(1 , "Loading: 100%");
    
}

    //this is the callable that contains the code that is run on the other thread.
//since the assetmananger is threadsafe, it can be used to load data from any thread
//we do *not* attach the objects to the rootNode here!
Callable<Void> loadingCallable = new Callable<Void>() {

    public Void call() {
        System.out.println("\n\n\n\n\nmonkey **************************");
        
        de.lessvoid.nifty.elements.Element element = nifty.getScreen("loadlevel").findElementByName("loadingtext");
        textRenderer = element.getRenderer(TextRenderer.class);
        nifty.gotoScreen("loadlevel");
        progressBarElement = nifty.getScreen("loadlevel").findElementByName("progressbar");        
        
        setProgress(0 , "Loading: 0%");
        
        /*
         * These reInitialize methods has been defined because some appStates 
         * require some fresh objects or parameters which cant be passed from
         * OVERRIDDEN setEnabled(). This can be fixed with some better design 
         * by probably moving some code around or making new appstates for
         * fresh objects..
         */
        setProgress(0.25f , "Loading: 25%");
        eds.reInitialize();
        setProgress(0.50f , "Loading: 50%");
        ppes.reInitialize();
        setProgress(0.75f , "Loading: 75%");
        mes.reInitialize(new XMLModelFactory(qId));              
        setProgress(1 , "Loading: 100%");
        
        return null;            
     }
};

@Override
public void update(float tpf) {
//do the following while game is running
if (load) {
if (loadFuture == null) {
//if we have not started loading yet, submit the Callable to the executor
loadFuture = exec.submit(loadingCallable);
}
//check if the execution on the other thread is done
else if (loadFuture.isDone()) {
//these calls have to be done on the update loop thread,
//especially attaching the terrain to the rootNode
//after it is attached, it’s managed by the update loop thread
// and may not be modified from any other thread anymore!
//nifty.gotoScreen(“end”);
//nifty.exit();
//guiViewPort.removeProcessor(niftyDisplay);
//flyCam.setEnabled(true);
//flyCam.setMoveSpeed(50);
System.out.println("\n\nLOADED");
nifty.gotoScreen(“hudScreen”);
//rootNode.attachChild(terrain);
load = false;
}
}
} [/java]

The flow starts from startGame(). I have read that its because that I’m modifying scenegraph. When I attaches the appStates it loads models and scene(but scenegraph nodes etc remain static) which according to my best knowledge is the culprit for slow loading. How should I try to approach the problem. My concern is simply to avoid and blank and stuck screens…

For the intial screen I sugest a textured quad in gui node, as it is faster thane everything else. Then wait a few frame to ensure it is actually rendered, then do the rest of your initializing logic.

Using app.enque(Callable<T>) will process that callable in the next loop update.

[java]
// display image

app.enque(new Callable<Boolean<() { loadScene(); return true; });

[/java]

This will ensure that when the current tick ends the image is rendered, then in the next tick it will start loading your scene.

android has a splash screen that comes on immediately and disappears after jME has loaded. In the MainActivity class, add

[java]splashPicID = R.drawable.filename_without_extension[/java]

You’ll need to add a folder called “drawable” to your resources folder in android

@Empire Phoenix said: For the intial screen I sugest a textured quad in gui node, as it is faster thane everything else. Then wait a few frame to ensure it is actually rendered, then do the rest of your initializing logic.

How should I wait for a few frames. Is it using Thread.sleep(x).
If yes what should be the value of x.

@simar.i3r said: How should I wait for a few frames. Is it using Thread.sleep(x). If yes what should be the value of x.

And here we have it - answer is of course 42, but have we found the question:
“How long should I sleep in order for my splash screen to load reliably on every possible platform and hardware?”.

@abies said: And here we have it - answer is of course 42, but have we found the question: "How long should I sleep in order for my splash screen to load reliably on every possible platform and hardware?".

Actually I the essence of my question was…
What code should I use to make it sleep so that my splash screen loads properly…

Well basically a control ont he rootnode with a counter that counds on update
then lets say if it reaches 5 remove the control and continue.