[PATCH] stopping offscreen Application hangs forever

Passing true to Application.stop() to wait for shutdown hangs when using an OffscreenSurface context. This patch fixes it.



[patch]diff --git a/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java b/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java

index 05f7143…8e92ef7 100644

— a/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java

+++ b/engine/src/lwjgl/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java

@@ -135,6 +135,7 @@ public class LwjglOffscreenBuffer extends LwjglContext implements Runnable {

renderer.cleanup();

pbuffer.destroy();

logger.info("Offscreen buffer destroyed.");

  •    super.internalDestroy();<br />
    

}



public void run(){

[/patch]



Here’s a testcase that shows the problem:

[java]import java.io.IOException;

import com.jme3.app.Application;

import com.jme3.system.JmeContext.Type;



public class Hang extends Application {

public static void main(String[] args) throws IOException {

Hang hang = new Hang();

hang.start(Type.OffscreenSurface);

System.in.read();

System.out.println(“Stopping”);

hang.stop(true);

}

}

[/java]

3 Likes

Thanks, fixed in SVN.

@Momoko_Fan said:
Thanks, fixed in SVN.


Thanks. I noticed this commit (r9753) also removed the "assert" on checkGLError() in LwjglOffscreenBuffer.runLoop. So now GL errors are checked every frame, before they were checked only if assertions were enabled. This may have a performance impact - glGetError is a "round-trip" transaction and now it's being called on every frame.
1 Like
@rectalogic said:
Thanks. I noticed this commit (r9753) also removed the "assert" on checkGLError() in LwjglOffscreenBuffer.runLoop. So now GL errors are checked every frame, before they were checked only if assertions were enabled. This may have a performance impact - glGetError is a "round-trip" transaction and now it's being called on every frame.

That call doesn't go to the GPU. It just queries the current error in OpenGL state. It should be called at least every frame to make sure there are no ignored errors. You will notice the LWJGL display and canvas classes already do this.