I’ve been working on my game project using JME for a small while now, and JME has been fantastic. But recently I’ve bumped into a nuisance of an issue while running my app in windowed mode - every so often (anywhere from ~3s - 10s) there is a very noticeable “freeze” or “stutter” (sometimes it even looks like rubber-banding). It is far less noticeable/frequent in fullscreen mode.
I’m certain it’s not caused by my app logic, as I used this bare-bones test app where the issue is present:
import com.jme3.app.SimpleApplication;
import com.jme3.scene.Spatial;
import com.jme3.util.SkyFactory;
public class TestApp extends SimpleApplication {
private Spatial SKYBOX;
private final String SKYBOX_TEXTURE = "Textures/Sky/PurpleSpace.dds";
private final SkyFactory.EnvMapType SKYBOX_TEXTURE_TYPE = SkyFactory.EnvMapType.CubeMap;
@Override
public void simpleInitApp() {
SKYBOX = SkyFactory.createSky(assetManager, SKYBOX_TEXTURE, SKYBOX_TEXTURE_TYPE);
rootNode.attachChild(SKYBOX);
var previewModel = assetManager.loadModel("Models/BoomBox.j3o");
previewModel.scale(100);
rootNode.attachChild(previewModel);
}
@Override
public void simpleUpdate(float tpf) {
}
}
I’ve conducted a bit of research, but haven’t found anything helpful - other than that it is perhaps a Windows/OpenGL-related issue?
If anyone could help me out with this issue, I’d greatly appreciate it!
I have vsync on (though I tried it with it off and the same issue persists).
I am indeed flying around and feeling the lag, and it happens every some odd seconds.
Windows version: Windows 11 Version 10.0.22631 Build 22631
GPU: RTX 3070 mobile, and an integrated Iris(R) Xe
I have the code loaded as a gradle project into Intellij, so I am running the main method through Intellij
JME sdk 3.6.1-stable
Sorry about the code snippet - this is actually the main method that’s firing off the simple application (I had pulled the code into its own app and ran it from the main method elsewhere).
Amended code:
package com.mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.light.LightProbe;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Spatial;
import com.jme3.system.AppSettings;
import com.jme3.util.SkyFactory;
public class Main extends SimpleApplication {
private Spatial SKYBOX;
private final String SKYBOX_TEXTURE = "Textures/Sky/PurpleSpace.dds";
private final SkyFactory.EnvMapType SKYBOX_TEXTURE_TYPE = SkyFactory.EnvMapType.CubeMap;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
SKYBOX = SkyFactory.createSky(assetManager, SKYBOX_TEXTURE, SKYBOX_TEXTURE_TYPE);
rootNode.attachChild(SKYBOX);
var previewModel = assetManager.loadModel("Models/BoomBox.j3o");
previewModel.scale(100);
rootNode.attachChild(previewModel);
// load ibl
Spatial probeHolder = getAssetManager().loadModel("abc.j3o");
LightProbe probe = (LightProbe) probeHolder.getLocalLightList().get(0);
probe.setPosition(Vector3f.ZERO);
probe.getArea().setRadius(1000f);
probeHolder.removeLight(probe);
getRootNode().addLight(probe);
}
@Override
public void simpleUpdate(float tpf) {
}
public AppSettings getSettings() {
return settings;
}
@Override
public void simpleRender(RenderManager rm) {
}
}
I guess you can just sample it then. See if there is some fishy going on. Like GC or some code (although this might not be your code then…). With jVisualVM for example.
Only thing that seems fishy to me is maybe(?) the high CPU time for glfwSwapBuffers and JNI.invokePV, but I’ve also heard that it’s probably normal, at least in this case since nothing is going on in the application…
In terms of memory allocations, jME3 Main occupies 5% of the heap dump, with the rest being RMI TCP which is just the connection to the VisualVM feed.
You can also see that do the GC match your stutter occasions. There are different GCs available to try if that is the issue. I haven’t seen this on my own projects ever, the default GC is pretty good.
I don’t run Windows 11… but why am I feeling like I have a vague memory of some article talking about getting games to run properly on Windows 11. (Not JME games but games in general…) Like, it keeps them from running at max performance or something.
@pspeed@tonihele Thanks for the tips, I’ll head in that direction next.
I also made a quick gif from my phone recording of my monitor capturing the issue here screen capture gif. At the beginning and the end, there is a bit of lag/rubber-banding. In this .gif I’m moving the camera to the left and strafing past the 3d model.
I might also be reaching a bit, but is there any chance I need to configure something for my application, if my laptop is hooked up to a monitor and using the monitor screen exclusively (display settings set to show only on the monitor)? I messed around a bit and ran my application on an older computer (hooked up to the same monitor) and got the same issue to occur. But if I don’t use a monitor and only use the laptop’s native screen, the issue doesn’t occur for either of my computers (or is just so subtle I don’t notice it).
I have a few questions since it happened to me before. I have a AMD graphics card and my monitor that is FreeSync compatible.
Did you install the monitor’s drivers? Windows default monitor drivers just allows 60Hz only and have poor latency. The drivers unlock what your monitor can do.
Is your Monitor GSync compatible?
Check your monitor cable (hdmi/display port) if it supports what your monitor can do.
Try turning off “Threaded Optimization” in your NVIDIA card settings. Years ago, I had a similar problem with my game, and NVIDIA was trying to do something fancy with threading that caused weird blocks with OpenGL.
@bloodwalker I haven’t installed any monitor drivers, have been using it out-of-the-box. Nice to know that - I’ll dig around for some drivers. Doesn’t appear to be Gsync, but is Adaptive Sync (unless that’s the same thing).