Settings Change Crash

So i’ve been doing a lot of beta testing for Spoxel lately and i’ve been getting a ton of bug reports related to changing graphics settings. Whenever a player changes the options in Spoxel it reapplies everything. I’ve had spotty reports of it happening in the main menu, but i’ve been consistently able to cause it to happen in game and only when the in full screen mode. The players get the following exception:

[2018-03-02 15:53:38] [SEVERE ] [] Uncaught exception thrown in Thread[jME3 Main,5,main] 
org.lwjgl.opengl.OpenGLException: Invalid value (1281)
	at org.lwjgl.opengl.Util.checkGLError(
	at org.lwjgl.opengl.WindowsContextImplementation.setSwapInterval(
	at org.lwjgl.opengl.ContextGL.setSwapInterval(
	at org.lwjgl.opengl.DrawableGL.setSwapInterval(
	at org.lwjgl.opengl.Display.setSwapInterval(
	at org.lwjgl.opengl.Display.setVSyncEnabled(
	at com.jme3.system.lwjgl.LwjglDisplay.createContext(
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(

I was able to debug it slightly and found that the value it was attempting to set was vsync. The relevant section of code I am calling is:

    AppSettings set = Voxelcraft.getInstance().getAppSettings();
    set.putFloat("musicVolume", musicVolume);
    set.putFloat("soundVolume", soundVolume);
    set.putBoolean("borderless", borderless);
    set.putFloat("gammaValue", gamma);
    set.putString("textureDetail", td.getSelection());
    set.putString("lightingDetail", ld.getSelection());
    set.putString("particleDetail", pd.getSelection());
    //set.putInteger("Samples", Integer.parseInt(samp.getSelection()));
    set.putBoolean("fxaa", fxaa);
    set.putBoolean("ssao", ssao);
    set.putBoolean("bloom", bloom);
    set.putBoolean("fogEffects", fog);
    set.putBoolean("showHealthbars", healthbars);
    System.setProperty("org.lwjgl.opengl.Window.undecorated", borderless ? "true" : "false");

    nifty.enableAutoScaling(dispSet.width, dispSet.height);


    // if we are running apply graphics changes
    if (Voxelcraft.hasState(GameState.class)) {
      GameState gs = Voxelcraft.getState(GameState.class);



I’m pretty much at my wits end on this one. I’ve toyed around with just not letting players change things like the resolution and vsync in game but i’ve had a few reports of it happening in the main menu now. Any ideas what could be going on?

I gave up on this a long time ago and went with a custom launcher that has a selection for resolution, vsync, AA, frequency and windowed/borderless. Not ideal, but hey Bethesda does it that way too so ¯\_(ツ)_/¯

That is pretty… unsettling. I assume it has something to do with something being rendered at the time the change happens, but even making sure it happens in the main thread doesn’t help. It annoys the crap out of me whenever games have launchers and you can’t change the settings in game. So I would really like to avoid that.

It seems like it is running into this error because jmonkey is still rendering something at the time. Is there a way to stop the opengl context and prevent rendering for awhile when you change settings?

Have you tried Lemur to see if that makes a diff?

This crash really has nothing to do with the GUI lib. It happens much less often in the main menu when it is just nifty rendering for example but I’ve had reports from a handful of players that they can still get the crash.