TestCanvas doesn't shutdown with JOGL renderer

When running the TestCanvas using the JOGL renderer, closing the JFrame does not exit the process. This works fine with the LWJGL renderer. To reproduce the issue simply add the following to TestCanvas:
[java]

public static void createCanvas(String appClass){
    AppSettings settings = new AppSettings(true);
    settings.setWidth(640);
    settings.setHeight(480);
    
    settings.setRenderer("JOGL"); // use JOGL instead of LWJGL


[/java]

are there more steps to properly shutdown the JOGL renderer?

The JOGL renderer is an experimental thing and not meant to be used at the moment. More so the two renderers are not meant to be interchanged or exhibit interchangeable behavior.

@normen said: The JOGL renderer is an experimental thing and not meant to be used at the moment. More so the two renderers are not meant to be interchanged or exhibit interchangeable behavior.

I’m not sure I understand. Am I not using the JOGL renderer correctly, or would you simply prefer it was not used at all? From what I’ve seen, most tests that use the JmeCanvasContext can be made to work with both renderers. Besides this shutdown bug, everything else works great.

Some background info: I’m experimenting with the JOGL renderer in order to find a better performing alternative to AwtPanel. From my testing, two JmeCanvasContexts (backed by JOGL) far outperform two AwtPanels.

The JOGL renderer is supposed to replace the LWJGL one at some point (probably 3.1). Its not tested or finished and might still have issues plus instantiating windows or panels with the JOGL renderer might change in the future when its actually used. I hope thats more clear.

@normen said: The JOGL renderer is supposed to replace the LWJGL one at some point (probably 3.1). Its not tested or finished and might still have issues plus instantiating windows or panels with the JOGL renderer might change in the future when its actually used. I hope thats more clear.

Understood, thanks for the explanation. For the time being I will keep testing with JOGL as this seems to be the only viable solution for multi-windowed use.

After some digging around I found the culprit keeping the process alive; the JOGL Animator. Running in debug mode on my IDE I can see a thread named “main-AWTAnimator” still running after the Application.stop() has been called. This is a non-daemon thread and there does not seem to be a way to interrupt it. Looking at the Animator source I see there is a stop() method but I can’t find a way to access. Out of options at this point I resort to killing the thread as follows:

[java]
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
app.stop();
Thread threads = new Thread[Thread.activeCount()];
Thread.enumerate(threads);
for (Thread thread : threads) {
if (thread.getName().endsWith(“AWTAnimator”))
thread.stop();
}
}
});
[/java]

This is not ideal but it is still much better than calling System.exit(0). Does anyone know how to stop this Animator cleanly from the JmeCanvasContext?

I’ve implemented a cleaner solution. By extending the JoglNewtCanvas I am able to access the Animator object and close it when the destroy() method is invoked:

[java]
public class CustomJoglNewtCanvas extends JoglNewtCanvas {

@Override
protected void startGLCanvas() {
    frameRate = settings.getFrameRate();
    super.startGLCanvas();
}

@Override
public void destroy(boolean waitFor) {
    super.destroy(waitFor);
    animator.stop();
}

}
[/java]

Then in the TestCanvas I simply add the following:

[java]
settings.setCustomRenderer(CustomJoglNewtCanvas.class);
[/java]

These modifications should really be committed to the JoglAbstractDisplay class to avoid the stalled shutdown problem. Can someone make these changes, or is there a process I should follow for contributing these changes?

Make a pull request on github is probably the easiest way forward. Stopping the animator seems correct to me but maybe @goussej can verify?

Pull request made.

@jmaasing It’s gouessej, not goussej. @Mr_Marbles When you need some help on a renderer maintained by the JogAmp community, rather contact us directly on IRC or on our official forum. Sorry for the late reply. I don’t want to be harsh but it’s absolutely impossible for me to spend hours on all forums to answer JogAmp users, please drive my “job” easier, come to me and don’t expect from me to be everywhere at the same time.

You have already accepted my pull request last year :smile:

Yes but my post above is still relevant. I’m rarely here, rather contact me elsewhere. I have no time to waste in useless debates and flame wars. When somebody asks for help about the JOGL backend, I don’t want to read any post about promoting other products.