Login  Register

Re: Possible NEWT EDT and rendering threads deadlock and/or race condition on window close

Posted by Sven Gothel on Nov 10, 2012; 2:20am
URL: https://forum.jogamp.org/Possible-NEWT-EDT-and-rendering-threads-deadlock-and-or-race-condition-on-window-close-tp4026842p4026843.html

On 11/09/2012 11:56 PM, GiGurra [via jogamp] wrote:

> 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.
>
Thank you for the great description.

>
> 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?

Yes, it defeats the purpose.

And I might get a hunch of what could happen,
i.e. the display() methods seems to make the window visible again.

>
>
> 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...)

It has become more easily to read recently while using a common subclass GLAutoDrawableBase,
however, .. sure, it's complex due to it's multi purpose.

Which versions did you use:
  - Java
  - JOGL
?

Of course it would be best if you can add a little code snippet (unit test at best).

~Sven



signature.asc (907 bytes) Download Attachment