Nifty-GUI loading takes too much time in mobile-app

After i add a nifty-gui to my mobile-app, i found it slow the loading so much.

My code:

[java]NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(

assetManager, inputManager, audioRenderer, guiViewPort);

// /** Create a new NiftyGUI object /

Nifty nifty = niftyDisplay.getNifty();

* Read your XML and initialize your custom ScreenController */

nifty.fromXml(“Interface/gui.xml”, “start”, this);

// attach the Nifty display to the gui view port as a processor



in [java]Nifty nifty = niftyDisplay.getNifty();[/java]

it takes about 700 millis,

but in [java] nifty.fromXml(“Interface/gui.xml”, “start”, this);[/java]

it takes about 15000 millis, it’s toooo much.

I make my simpleApplication to implements ScreenController but do nothing in bind()/onStartScreen()/onEndScreen()

Any idea to reduce the loading time? Or i make something wrong?

You can split your gui in several xml files and load them on demand instead of loading all at the start of the application.

But you may have “freezes” when loading the new file.

Another solution is to display a splash screen to help the user to wait. A lot of android games does that. You are always more inclined to be patient when “loading…” is written on the screen :stuck_out_tongue:

@nehon said:
You are always more inclined to be patient when "loading..." is written on the screen :p

It's not like you have a choice anyway. ;)

But what @nehon says makes a lot of sense for Andoid games because everybody hates (on Android or anywhere else) waiting for stuff to load while in mid-play. Hitching is NOT a developer's friend.
1 Like

Thanks first.

But what is the problem is my gui is really simple…it just contains two buttons and no image.

[xml]<useControls filename="nifty-default-controls.xml" />

<useStyles filename="nifty-default-styles.xml" />

<screen id="start" controller="mygame.Main">

<layer id="foreground" backgroundColor="#0000" childLayout="horizontal">

<!-- … -->

<panel id="panel_bottom_left" height="50%" width="50%" valign="center" childLayout="center"


<control name="button" label="Start" id="StartButton" align="center" valign="center">

<interact onClickRepeat="zoomOut()"/>



<panel id="panel_bottom_right" height="50%" width="50%" valign="center" childLayout="center"

backgroundColor="#555a" visibleToMouse="true">

<control name="button" label="Quit" id="QuitButton" align="center" valign="center">

<interact onClickRepeat="zoomIn()" />





Do you have nifty logging turned down? It’s very verbose and android logging is notoriously slow.

@zarch said:
Do you have nifty logging turned down? It's very verbose and android logging is notoriously slow.

yes.. after i add [java] Logger.getLogger("de.lessvoid.nifty").setLevel(Level.SEVERE);
it also take almost 10000 millis.

I notice that when i load the nifty the GC will be very busy, is so many objects creating?
04-06 17:40:36.319 2414 2424 D dalvikvm: GC_FOR_MALLOC freed 15348 objects / 1261848 bytes in 67ms
04-06 17:40:36.593 2414 2424 D dalvikvm: GC_FOR_MALLOC freed 18137 objects / 1413328 bytes in 68ms
04-06 17:40:36.913 2414 2424 D dalvikvm: GC_FOR_MALLOC freed 25781 objects / 1726320 bytes in 70ms
04-06 17:40:37.210 2414 2424 D dalvikvm: GC_FOR_MALLOC freed 22656 objects / 1537672 bytes in 69ms

Are you running the nightly or stable? I remember a recent post saying that nifty had been sped up by 400% by some changes although I think that was more around rendering than loading.

Disable nifty logging, it hogs performance esp. on android.

There’s a new version of nifty released that significantly reduces GC. Probably we should update to it soon …