FengGUI running slow

Hi everyone,

I've been working on a game for over a year, off and on. I will be distributing the game to some middle-schools in about a week.



The problem I've run into when testing on their machines is that the FPS drop way down compared to running it on my developer machine (OBVIOUSLY, right?) What I've discovered is that rendering the game world, with all the textured models, runs perfectly smooth. I figured this out by removing all GUI elements. When the GUI IS displayed, the game slows way down.



I'm running old versions of both FengGUI and jME, but I'm hoping someone can still help me. The way I'm displaying the GUI is by manually calling the display function in my GameState's render function (of course, AFTER my scenenode is rendered).



Thanks for your help in advance!

Of course.



I initialize it by:

guiDisplay = new org.fenggui.Display(new org.fenggui.render.lwjgl.LWJGLBinding());





These are the render and update methods.

[pre] public void render(float tpf) {

this.display.getRenderer().draw(rootNode);



if(guiDisplay.isVisible())

guiDisplay.display();

}



public void update(float tpf) {

guiDisplay.updateMinSize();

guiDisplay.layout();

}

[/pre]



In the base GameState that runs the GUI update and render:

[pre] @Override

public void update(float tpf) {

input.update(tpf);



deltaTime += tpf;

//break this down into 0.02 chunks

while(deltaTime > UPDATE_RATE){

deltaTime -= UPDATE_RATE;



super.update(UPDATE_RATE);



inputHandler.update(UPDATE_RATE);



if(rootNode != null)

rootNode.updateGeometricState(UPDATE_RATE, true);



if(gameGUI != null)

gameGUI.update(UPDATE_RATE);

}

}



/**

  • Render the gameWorld and GUI components

    */

    @Override

    public void render(float tpf) {



    super.render(tpf);



    long before = System.currentTimeMillis();



    //render buttons, labels, and other GUI components

    if(gameGUI != null)

    gameGUI.render(tpf);



    System.out.println("Render gui time: " + (System.currentTimeMillis() - before));



        }

    [/pre]



    I hope this helps. I'll be glad to give anything else that might help.

    Another thing that might help to mention is that just adding some time calculations, it seems the gui rendering takes about 3-4ms on average, where the game node rendering takes around 1ms usually.

Can you show what exactly you do to call FengGUI in your render method?

i guess you have to profile a bit to see the bottleneck.



Maybe the layout() call in the update method uses alot time?

I took your advice and set up Eclipse for profiling.



The results came out where the GUI's render statistics are:

Base Time: 4.31  Average Base Time: 0.001537  Cumulative Time: 6.8  Calls: 2800  Cumulative CPU: 5.5



The GUI's update stats are:

Base Time: 6.28  Average Base Time: 0.000206  Cumulative Time: 6.28  Calls: 30500 Cumulative CPU: 8.6





The GUI's update stats are for those lines you suggested might use too much time (layout() ). With those lines removed, obviously the GUI stats are removed from the processing time.



I haven't profiled before, so I'm not sure how to make sense of these numbers. I know what each means (from help manuals and such) but not how to judge if those lines were actually a bottleneck. It seems to me that the Average Base Time of a single execution being 0.000206 is very small, and should have no impact if they are included. But, they are run 30,000 times, compared to 2800, which means that small average base time is much more significant than it seems. Is this reasoning correct, or am I missing something?



Do you think these few lines have a big impact? Or might it be something else? What is the best way to interpret these profiling statistics?



I'm going to be testing this change on the machines tomorrow. The problem is the location is over an hour away, so I want to go there as prepared as I can.

i was hoping it shows that layout() takes much time :slight_smile:



Update is called much much more than render tho, because of your game loop.

I would try to throttle the gui update(), so that updateMinSize() and layout() is only called as much as render().



Maybe move them into the render method?



edit: darn typos

tjloughl said:

Of course.

[pre] public void render(float tpf) {
this.display.getRenderer().draw(rootNode);

if(guiDisplay.isVisible())
guiDisplay.display();
}

public void update(float tpf) {
guiDisplay.updateMinSize();
guiDisplay.layout();
}
[/pre]


You should never call "layout" or "updateMinSize" constantly. Both are very processing intense. In your case updateMinSize doesn't do much as the call travels from a leaf to the root of the visual tree. Layout travels the other way and will most likely be the reason for your slowdowns. I wouldn't know a reason to call both of them constantly anyway ;). UpdateMinSize should be correctly called by FengGUI itself and layout just needs to be called if you add or remove something from the UI.

I made these changes as mentioned. It really increased my framerate!



Also, the main problem was the driver. I guess I didn't find the correct driver the first time around. Sorry for the late reply. Been testing to make sure everything works.



Thanks for all of your help