Framerate on Android with Nifty

I was wondering if anyone has any framerate references with Nifty running on Android. I have what I think is a simple nifty screen running, but I’m getting a framerate of 4 when the nifty screen is used compared to 60 if I don’t load the nifty screen. Are other people seeing the same result or am I doing it completely wrong? I also have the adb logcat if that is useful to anyone.



main game class:

[java]

package mygame;



import com.jme3.niftygui.NiftyJmeDisplay;

import de.lessvoid.nifty.Nifty;

import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.Node;

import com.jme3.scene.shape.Box;

import java.util.logging.Level;

import java.util.logging.Logger;



public class Main extends SimpleApplication {



private static final Logger logger = Logger.getLogger(Main.class.getName());



private NiftyJmeDisplay niftyDisplay;

private Nifty nifty;

private Node sceneNode = new Node(“sceneNode”);



public static void main(String[] args) {

Main app = new Main();

app.start();

}



@Override

public void simpleInitApp() {



// Logger.getLogger("").setLevel(Level.SEVERE);

Logger.getLogger("").setLevel(Level.ALL);



flyCam.setDragToRotate(true);

flyCam.setEnabled(true);

flyCam.setMoveSpeed(50);



niftyDisplay = new NiftyJmeDisplay(assetManager,

inputManager,

audioRenderer,

guiViewPort);

nifty = niftyDisplay.getNifty();



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



guiViewPort.addProcessor(niftyDisplay);



Box b = new Box(Vector3f.ZERO, 1, 1, 1);

Geometry geom = new Geometry(“Box1”, b);

Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Blue);

geom.setMaterial(mat);

geom.setLocalTranslation(0, 0, 0);

sceneNode.attachChild(geom);

rootNode.attachChild(sceneNode);



}



@Override

public void simpleUpdate(float tpf) {



}



}



[/java]



nifty controller class:

[java]

package mygame;



import de.lessvoid.nifty.Nifty;

import de.lessvoid.nifty.screen.Screen;

import de.lessvoid.nifty.screen.ScreenController;

import java.util.logging.Level;

import java.util.logging.Logger;



public class MyStartScreen implements ScreenController {



Logger logger = Logger.getLogger(MyStartScreen.class.getName());



private Nifty nifty;

private Screen screen;



public MyStartScreen() {



}



/** Nifty GUI ScreenControl methods /



public void bind(Nifty nifty, Screen screen) {

logger.log(Level.SEVERE, “bind starting”);

this.nifty = nifty;

this.screen = screen;

}



public void onStartScreen() { }



public void onEndScreen() { }



/
* custom methods */

public void moveForward() {

logger.log(Level.SEVERE, “moveForward”);

}



public void moveBack() {

logger.log(Level.SEVERE, “moveBack”);

}



public void moveLeft() {

logger.log(Level.SEVERE, “moveLeft”);

}



public void moveRight() {

logger.log(Level.SEVERE, “moveRight”);

}



public void throwBag() {

logger.log(Level.SEVERE, “throwBag”);

}



}



[/java]



nifty xml file:

[java]

<?xml version=“1.0” encoding=“UTF-8”?>

<nifty

xmlns=“http://nifty-gui.sourceforge.net/nifty.xsd

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance

xsi:schemaLocation=“http://nifty-gui.sourceforge.net/nifty.xsd http://nifty-gui.sourceforge.net/nifty.xsd

>

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

<useControls filename=“nifty-default-controls.xml” />



<screen id=“start” controller = “mygame.MyStartScreen”>

<layer

id=“foreground_hud” childLayout=“horizontal” backgroundColor="#00000000">

<panel

id=“panel_hud_top_middle” width=“100%” height=“20%”

childLayout=“horizontal” backgroundColor="#00000000">

<control width=“20%” height=“100%”

name=“button” label=“FWD” id=“ForwardButton”

align=“center” valign=“center”

visibleToMouse=“true”>

<interact onClick=“moveForward()”/>

</control>

<control width=“20%” height=“100%”

name=“button” label=“LEFT” id=“LeftButton”

align=“center” valign=“center”

visibleToMouse=“true”>

<interact onClick=“moveLeft()”/>

</control>

<control width=“20%” height=“100%”

name=“button” label=“THROW” id=“ThrowButton”

align=“center” valign=“center”

visibleToMouse=“true”>

<interact onClick=“throwBag()”/>

</control>

<control

width=“20%” height=“100%”

name=“button” label=“RIGHT” id=“RightButton”

align=“center” valign=“center”

visibleToMouse=“true”>

<interact onClick=“moveRight()”/>

</control>

<control width=“20%” height=“100%”

name=“button” label=“BACK” id=“BackButton”

align=“center” valign=“center”

visibleToMouse=“true”>

<interact onClick=“moveBack()”/>

</control>

</panel>

</layer>

</screen>



<screen id=“end” controller = “mygame.MyStartScreen”>

</screen>



</nifty>



[/java]

I don’t know about Android, but I do know that using labels/text boxes that are updated rapidly and frequently are hellish with Nifty. I usually run around 500 FPS but if the player ship is moving at full speed I often get long and debilitating hitches that can last half a second to 2-3 seconds.



There were several fixes and improvements recently that have alleviated the problem by a wide margin, but there’s still lots of work to do there I fear.



I know it doesn’t answer your question, but I’m sure those two are related. Hopefully I’m wrong!

Sorry to bump this thread, but I was wondering if anyone has got nifty running on Android at an acceptable / usable framerate? I’m really struggling to figure out how we are expected to use Nifty for the UIF when the performance of the app takes such a dive.



Is Nifty really a viable option for Android?

I didn’t test nifty on android, but with friend we are making some kind of board game on android.

We chose the path of a GLView + native android UI, and even this way the app suffer some slow downs when the UI pops in…

But it’s quite still usable (around 5 fps slow down among 25 on a eepad transformer) but it’s not great.



Anyway maybe you could look in that direction it could be a viable alternative (be careful btw the native UI and the JME render don’t run in the same thread so you have to enqueue scene graph modifications to the render thread).

Nah, we should just look into what slows down nifty. This is like using AWT for a game UI :stuck_out_tongue:

I’m willing to do some grunt work to try to investigate, but I’m not sure how to start. If someone can suggest where to start and how to investigate (broad terms) then I can look into it. I’m partly through designing my HUD using pictures in the guiNode and touch listeners, but I’l rather not have to for future apps.