Hi,
I’m running the jMonkeyEngine SDK 3.1-alpha1 on Windows 7 64-Bit (but the problem occured on 3.0 stable too).
I’m experiencing some slight stuttering / hiccups in the rendering even when running very simple apps like the code snippet below.
I tried to log the frame rates over time and I’m not sure if there is a correlation.
The stuttering happens inconsistently about every 3 seconds and right after the application starts (the latter wouldn’t be much of a problem on its own).
The stuttering itself is very subtle, but it is more noticable at lower framerates, hence the limit in the code snippet to 30 fps.
Here is a graph of a log for about 15 secs. (“fps” should really be “tpf”):
It doesn’t look like the actual frame rate reflects the problem. I’m not sure if the spike at about 9 secs. correlates to some visual stuttering (there should definitly be more spikes).
While doing research on the forums I read about increasing the heap memory size for the Garbage Collection (of which I have no experience with) and added this to the VM options in the projects Run settings: -Xms1024m -Xmx1024m -XX:MaxDirectMemorySize=2048m
But it didn’t change anything. It would have surprised me anyway if there would be memory problems in such a simple scene.
Here is the basic testing application:
public class Main extends SimpleApplication
{
BufferedWriter log;
Geometry geometry;
float time;
public static void main( String[] args )
{
// Settings
AppSettings settings = new AppSettings( true );
settings.setTitle( "Test" );
settings.setResolution( 1024, 768 );
settings.setFullscreen( false );
settings.setFrameRate( 30 );
// Create and start app
Main app = new Main();
app.setShowSettings( false );
app.setSettings( settings );
app.start();
}
private Main()
{
super( new StatsAppState(), new DebugKeysAppState() );
}
@Override
public void simpleInitApp()
{
// Log
try
{
File logFile = new File( System.getProperty( "user.dir" ) + "/log.csv" );
System.out.println( "Path: " + logFile.getCanonicalPath() );
log = new BufferedWriter( new FileWriter( logFile ) );
log.write( "time,fps\n" );
}
catch ( Exception e )
{
e.printStackTrace();
}
// Test Scene
geometry = new Geometry( "TestGeom", new Box( 2, 2, 2 ) );
geometry.setMaterial( new Material( assetManager, "Common/MatDefs/Misc/ShowNormals.j3md" ) );
rootNode.attachChild( geometry );
// Time
time = 0.0f;
}
@Override
public void destroy()
{
super.destroy();
// Log
try
{
log.close();
}
catch ( Exception e )
{
e.printStackTrace();
}
}
@Override
public void simpleUpdate( float tpf )
{
// Animate
geometry.rotate( 0, tpf * 1.5f, 0 );
// Log
try
{
log.write( time + "," + tpf + "\n" );
}
catch ( Exception e )
{
e.printStackTrace();
}
// Time
time += tpf;
}
@Override
public void simpleRender( RenderManager rm )
{
//TODO: add render code
}
}
On a side note the problem also occurs in more complex projects, where I was even using framerate independent timing.
Do other people experience similar problems?
What could be a possible reason?
Thanks in advance for any advice!