This is quite strange. I am getting errors and warnings when I run my application in a loop. The errors and warning are sporadic but happen very often.
I pared my code down to a test case. Here is the main class:
package test._3dmathpuzzles.cubes;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.shape.Box;
import com.jme3.system.JmeContext;
import java.io.File;
public class CubePuzzleGenerator extends SimpleApplication {
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.White);
Mesh m = new Box(10, 10, 10);
Geometry geom = new Geometry("Box", m);
Material mat = new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
ColorRGBA bgColor = ColorRGBA.Black;
mat.setColor("Color", bgColor);
geom.setMaterial(mat);
rootNode.attachChild(geom);
ScreenshotAppStateWithCallbacks ssAppState = new ScreenshotAppStateWithCallbacks(
"C:"+File.separator+"Tmp"+File.separator,
"test");
ssAppState.setIsNumbered(false);
ssAppState.setWriteImageFileCallback(new Runnable() {
@Override
public void run() {
stop();
}
});
stateManager.attach(ssAppState);
ssAppState.takeScreenshot();
}
public static void main(String[] args)
throws Exception {
for( int i = 0; i<5; i++ ) {
System.out.println("Starting iteration "+i);
new CubePuzzleGenerator().start(JmeContext.Type.OffscreenSurface);
System.out.println("Ended iteration "+i);
}
}
}
Here is the helper class:
package test._3dmathpuzzles.cubes;
import com.jme3.app.state.ScreenshotAppState;
import java.io.File;
import java.io.IOException;
public class ScreenshotAppStateWithCallbacks extends ScreenshotAppState {
private Runnable writeImageFileCallback;
public ScreenshotAppStateWithCallbacks(String filePath, String fileName) {
super(filePath, fileName);
}
public void setWriteImageFileCallback(Runnable writeImageFileCallback) {
this.writeImageFileCallback = writeImageFileCallback;
}
@Override
protected void writeImageFile(File file) throws IOException {
super.writeImageFile(file);
if( writeImageFileCallback != null )
writeImageFileCallback.run();
}
}
I just ran it and I got this output:
Starting iteration 0
Feb 28, 2023 12:25:40 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.5.2-stable
* Branch: HEAD
* Git Hash: 8ab3d24
* Build Date: 2022-04-21
Ended iteration 0
Starting iteration 1
Ended iteration 1
Starting iteration 2
Ended iteration 2
Starting iteration 3
Ended iteration 3
Starting iteration 4
Ended iteration 4
Feb 28, 2023 12:25:40 PM com.jme3.app.LegacyApplication handleError
SEVERE: Win32: Failed to register window class: Class already exists.
java.lang.Exception: Win32: Failed to register window class: Class already exists.
at com.jme3.system.lwjgl.LwjglWindow$1.invoke(LwjglWindow.java:199)
at org.lwjgl.glfw.GLFWErrorCallbackI.callback(GLFWErrorCallbackI.java:43)
at org.lwjgl.system.JNI.invokeI(Native Method)
at org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:1047)
at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:203)
at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:529)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:662)
at java.lang.Thread.run(Thread.java:750)
Feb 28, 2023 12:25:40 PM com.jme3.app.LegacyApplication handleError
SEVERE: Win32: Failed to register window class: Class already exists.
java.lang.Exception: Win32: Failed to register window class: Class already exists.
at com.jme3.system.lwjgl.LwjglWindow$1.invoke(LwjglWindow.java:199)
at org.lwjgl.glfw.GLFWErrorCallbackI.callback(GLFWErrorCallbackI.java:43)
at org.lwjgl.system.JNI.invokeI(Native Method)
at org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:1047)
at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:203)
at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:529)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:662)
at java.lang.Thread.run(Thread.java:750)
Feb 28, 2023 12:25:40 PM com.jme3.app.LegacyApplication handleError
SEVERE: Win32: Failed to register window class: Class already exists.
java.lang.Exception: Win32: Failed to register window class: Class already exists.
at com.jme3.system.lwjgl.LwjglWindow$1.invoke(LwjglWindow.java:199)
at org.lwjgl.glfw.GLFWErrorCallbackI.callback(GLFWErrorCallbackI.java:43)
at org.lwjgl.system.JNI.invokeI(Native Method)
at org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:1047)
at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:203)
at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:529)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:662)
at java.lang.Thread.run(Thread.java:750)
Feb 28, 2023 12:25:40 PM com.jme3.app.LegacyApplication handleError
SEVERE: Win32: Failed to register window class: Class already exists.
java.lang.Exception: Win32: Failed to register window class: Class already exists.
at com.jme3.system.lwjgl.LwjglWindow$1.invoke(LwjglWindow.java:199)
at org.lwjgl.glfw.GLFWErrorCallbackI.callback(GLFWErrorCallbackI.java:43)
at org.lwjgl.system.JNI.invokeI(Native Method)
at org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:1047)
at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:203)
at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:529)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:662)
at java.lang.Thread.run(Thread.java:750)
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x712f6160, pid=18120, tid=0x00005788
#
# JRE version: Java(TM) SE Runtime Environment (8.0_351-b10) (build 1.8.0_351-b10)
# Java VM: Java HotSpot(TM) Client VM (25.351-b10 mixed mode, sharing windows-x86 )
# Problematic frame:
# CFeb 28, 2023 12:25:40 PM com.jme3.app.LegacyApplication handleError
SEVERE: Failed to create display
java.lang.IllegalStateException: Unable to initialize GLFW
at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:204)
at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:529)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:662)
at java.lang.Thread.run(Thread.java:750)
Feb 28, 2023 12:25:40 PM com.jme3.app.LegacyApplication handleError
SEVERE: Failed to create display
java.lang.IllegalStateException: Unable to initialize GLFW
at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:204)
at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:529)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:662)
at java.lang.Thread.run(Thread.java:750)
[glfw.dll+0x6160]Feb 28, 2023 12:25:40 PM com.jme3.app.LegacyApplication handleError
SEVERE: Failed to create display
java.lang.IllegalStateException: Unable to initialize GLFW
at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:204)
at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:529)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:662)
at java.lang.Thread.run(Thread.java:750)
Feb 28, 2023 12:25:40 PM com.jme3.system.lwjgl.LwjglWindow run
SEVERE: Display initialization failed. Cannot continue.
Feb 28, 2023 12:25:40 PM com.jme3.system.lwjgl.LwjglWindow run
SEVERE: Display initialization failed. Cannot continue.
Feb 28, 2023 12:25:40 PM com.jme3.system.lwjgl.LwjglWindow run
SEVERE: Display initialization failed. Cannot continue.
Execution protection violation
[thread 22508 also had an error]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# G:\My Drive\Dev\3DMathPuzzlesWeb\hs_err_pid18120.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
If you look at the output, the error comes after the loop finishes its final loop. There is no code to execute after that.
I am also sporadically getting this warning:
WARN: Driver claims that default framebuffer is not sRGB capable. Enabling anyway.
Any ideas what is going on?