Hello,
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.
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!
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.
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.
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)
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?
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.
So, I ran your test case on my end, and I made a few observations:
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)
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).
The darkening barely affects color channels close to the maximum
Before:
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.