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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

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

Reply | Threaded
Open this post in threaded view
|

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

Sven Gothel
Administrator
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
Reply | Threaded
Open this post in threaded view
|

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

GiGurra
Sry I havent gotten back to you yet...I will try to provide a .java file with source code asap. (tonight or tomorrow).

I've been busy lately with work and learning Scala (Scala and Jogl....wonderful combination :))
Reply | Threaded
Open this post in threaded view
|

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

GiGurra
HAH. It seems to be my mistake. I was using RC8 I think and after, updating JOGL & Gluegen to RC11 I am unable to reproduce the problem. :)