White screen on context restart

I am trying to troubleshoot why when I restart the jme context, the new window just comes up white. But the app is not frozen, key input still works and the window is responsive., the screen is just rendering white. I built a test case, but the test case works correctly.

I have been disabling code within my client trying to figure out why the context restart is not working, but I have not had any luck yet. Does anyone have an idea as to what is going on, or a way to troubleshoot it so I can narrow down what I have broken?



I have had this same issue when I was making an app with jME. It’s really annoying when it comes up because it doesn’t typically tell you what’s wrong in the logs, and from what I know there are many different reasons why it occurs.

One way it happened with me that I can remember from the top of my head, is when I was using the wrong bullet library (i was using the non android library by accident) for my app, but the actual code was completly fine, void of any issues.

Turning on debug mode (using android studio) will show the error in the logs when launching it up, so that might give you a hint on what’s wrong, but from my belief the reason this is caused is that something outside of the code of the game, but rather the android project structure.

1 Like

Hmm. I am not using android, but my test case does not have any physics in it, I am using Minie in my project, and I will add it to my test and see what happens. Thanks!

1 Like

OK, adding Minie to my test project did not cause the issue to occur. Does not look like an issue related to physics.

AH, I figured it out, my test was using LWJGL2 renderer, not 3.

This looks to be an issue with the LWJGL-3 Renderer, see simple test:

package io.tlf.jme.test;

import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.system.AppSettings;

import java.io.IOException;

public class SettingsMain extends SimpleApplication {

    private boolean vsync;

    public void simpleInitApp() {
        vsync = getContext().getSettings().isVSync();

        ActionListener tab = (name, isPressed, tpf) -> {
            if (!isPressed) {
        inputManager.addMapping("tab", new KeyTrigger(KeyInput.KEY_TAB));
        inputManager.addListener(tab, "tab");

    public static void main(String[] args) throws IOException {
        AppSettings settings = new AppSettings(true);
        SettingsMain main = new SettingsMain();

EDIT: Also, on LWJGL-2 although the context comes back, colors are very dark when the new window comes up.


Maybe the gamma correction boolean in appSettings could be getting reset on the restart?

For LWJGL-2:
Before Context Restart:

After Context Restart:

For LWJGL-3:
Before Context Restart:

After Context Restart:

As for gamma on lwjgl-2 after restart, I put System.out.println(getContext().getSettings().isGammaCorrection()); in simpleUpdate and the value did not change after the context restart. I am not too concerned about it though as I mainly use lwjgl3, so I am much more concerned about the context not coming back up for it.

1 Like

Are you getting the standard log output?

Here is the code that actually runs when you try to restart a LWJGL3 context:

Looks like it should be logging a success message, or exception of the code thinks something went wrong…

And the key and mouse input will restart correctly even if the graphics context barfs.

1 Like

May you try with different versions of jme3-lwjgl3 module? (3.2, 3.3, and 3.4 current snapshot)


Tried with a blue box example on different versions of LWJGL3 and for me it shows a black screen after restarting context.

1 Like

Here is the console output: jme3-context-restart.txt · GitHub

It does log “Display restarted.”
I do not see any errors that stand out.

On my system, I never get the “Click Me!” button at all.

  • Just initializes with a black screen & the statistics sidebar.
  • Has grabbed Mouse/Keyboard input. No cursor feedback.
  • Tab key gives me my mouse back, but I lose the stats

Note about v-sync: I re-wrote the example a bit to try to force v-sync off, and ran into the same thing immediately, and I’ve always had issues trying to turn off v-sync when running the example apps.

I think that my driver does not support a non-v-sync display (Older laptop card w/mesa driver.)

Was your original project (not the minimal example) also playing with the v-sync setting? If so, perhaps this is more of a v-sync status/support issue than a bug in restartContext per. se.

1 Like

Which, (Duh) is of course because that must be part of your original application, rather than the test case. Never Mind.

However, I have found that once I’ve hit tab, the running app pegs one of my CPU cores to 100%, and starts churning through memory. (Before triggering the restart, I’m looking at about 25% of 1 core)

Working on getting some actual thread traces…

1 Like

If you would like I can provide the test case include the javafx component, but it is not necessary to test this issue.

No, I can see that I am moving the flycam, etc. I was just a little disoriented because I didn’t realize that the screenshots were from the original project.

Update on the CPU use: I tried commenting out the call to swap the v-sync mode.

  • Pegged thread is gone
  • Still lose the statistics window

So, maybe I was seeing two different issues?

Can you confirm if this test-case over-uses CPU on your system?

Hmm, I am not seeing the CPU usage increase with the VSync

1 Like

Were you able to get the time to work on tracking down the issue?

Not much.

  • I do believe that the CPU spike happens when v-sync is disabled, due to the render loop running without pause. Not related to this issue.
  • I’ve not been able to collect a heap dump when the render is running correctly for comparison purposes, as the app UI captures my mouse until after I’ve triggered the issue.
1 Like

Continuing the discussion from Updating Display Settings Darkens Scene:

So, I ran your test case on my end, and I made a few observations:

  1. The screen blank only seems to happen on the jme3-lwjgl3 library when messing with the “setRenderer” option in the app settings (specifically, setting it to any OPENGL version 3 or 4). Setting it to OpenGL 2 or not setting it at all doesn’t seem to blank it (although colors will still darken)
  2. A regular context restart won’t trigger anything normally on the jme3-lwjgl library. However, setting stencil bits, depth bits, bits per pixel, or samples prior to the restart will trigger any of the above behavior (darkening colors on OPENGL2 compatibility, screen blanking on OPENGL 3 or 4 compatibility).
  3. The darkening barely affects color channels close to the maximum


    There does appear to be a difference, but it is nearly imperceptable. It only really begins to take effect on lower values of the color channel.

@yaRnMcDonuts actually mentioned gamma correction, so I did some more experiemtation.
Gamma Correction off:

Gamma Correction on:

From what I can see, restarting the context seems to turn the gamma correction system off, despite what is in the settings. Chances are, there is probably a bug somewhere in this. I’ll do some digging and see if I can locate it.

UPDATE: When the application runs for the first time in jme3-lwjgl3, isGammaCorrection is called first from LwjglWindow’s createContext(AppSettings) method, but is then called twice on LwjglContext’s initContextFirstTime() method. However, when I restart the context, it is only called from LwjglWindow, and not LwjglContext. Apparently, the lines in LwjglContext are critical for enabling gamma correction in the jme3-lwjgl3 library.
UPDATE 2: For the jme3-lwjgl library, isGammaCorrection() isn’t called from anywhere but LwjglContext’s initContextFirstTime() method. Naturally, this method is not called when restarting the context. Oddly enough, though, this doesn’t seem to matter if the samples or bits or anything haven’t been changed. I’m guessing there may be some sort of flag that checks if these have changed for jme3-lwjgl.