Possible NEWT EDT and rendering threads deadlock and/or race condition on window close
Posted by GiGurra on Nov 09, 2012; 10:56pm
URL: https://forum.jogamp.org/Possible-NEWT-EDT-and-rendering-threads-deadlock-and-or-race-condition-on-window-close-tp4026842.html
I've been seeing what I think is a race and/or deadlock issue in GlWindow's destroy() method. As I wont be home until sunday I'll try to write down here as much information as I have and try to upload some sample code on sunday.
I have only tried this on win7 64 bit with 64bit jdk, so I can't tell how it runs otherwise.
The problem I'm seeing is that sometimes when closing (by clicking the X in the top right corner) a newt window, the window closes and then pops up again! Some other times it just freezes.
This happens on multiple jogl projects I am developing and also on simple test code.
It happens regardless if I use an Animator to call display or just do it with my own for/while loop.
It usually happens at specific render frequencies. Having a sleep period of 4-6 ms (i.e. using Thread.sleep(6)) seems to make the issue happen more often (one out of 2-3 attempts), and having more windows open may also increase the frequency of the problem.
I have found a way to geta around this problem using my own render loop (skippin the animator), by invoking display from the EDT thread and having it wait for the display to finish - this way there is no race and no freezes or unexpected behaviour, but it sort of kills the purpose of having a separate asynchronous event dispatcher thread, right?
I'll get back with more info, but as I'm not a JOGL expert I could not narrow down the issue very much further (Been trying to navigate the Jogl java src with eclipse, but....it's a lot of code... :P. And GlWindow doesn't seem to be the most simple class in the house...)
How to recreate the issue:
If you don't want to wait for me to upload a test project, create a few stubbed GlEventListener with GlWindows. Put them in a render loop with a Thread.sleep(6) and start X-closing the windows down. You should see the issue fairly quick. (Perhaps it will take a few attempts)