Deadlock with NewtCanvasAWT

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

Deadlock with NewtCanvasAWT

mbastian
Hi, I'm tracking down a bug and I would like some advice the the best way to handle this multithreading issue. This issue only appears on Mac OS X. I'm using JDK8 and tested with multiple JRE versions. I'm using JOGL 2.3.2 but also tested with 2.3.1, same result.

My application encounters an hanging bug at init/start where threads are waiting on each other (or at least that's what I imagine). To keep it simple, the application has a complex Swing GUI with one panel being a NewtCanvasAWT.

While hanging, the EDT Thread (AWT-EventQueue-0) has the following stack

Name: AWT-EventQueue-0
State: WAITING on java.lang.Object@2dbec237 owned by: AWT-EventQueue-0-Display-.macosx_nil-1-EDT-1
Total blocked: 70  Total waited: 40

Stack trace: 
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:502)
jogamp.newt.DefaultEDTUtil.invokeImpl(DefaultEDTUtil.java:242)
jogamp.newt.DefaultEDTUtil.invoke(DefaultEDTUtil.java:165)
jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:442)
jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2782)
jogamp.newt.WindowImpl.setVisible(WindowImpl.java:1330)
jogamp.newt.WindowImpl.setVisible(WindowImpl.java:1335)
com.jogamp.newt.opengl.GLWindow.setVisible(GLWindow.java:578)
com.jogamp.newt.awt.NewtCanvasAWT.attachNewtChild(NewtCanvasAWT.java:1057)
com.jogamp.newt.awt.NewtCanvasAWT.validateComponent(NewtCanvasAWT.java:956)
com.jogamp.newt.awt.NewtCanvasAWT.reshape(NewtCanvasAWT.java:750)
   - locked java.lang.Object@67faa7e9
   - locked java.awt.Component$AWTTreeLock@4b9aeb19
java.awt.Component.setBounds(Component.java:2263)
...

And the AWT-EventQueue-0-Display-.macosx_nil-1-EDT-1 thread has the following stack:
Name: AWT-EventQueue-0-Display-.macosx_nil-1-EDT-1
State: WAITING on java.lang.Object@f8a24ae
Total blocked: 3  Total waited: 4

Stack trace: 
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:502)
jogamp.nativewindow.macosx.OSXUtil.RunOnMainThread(OSXUtil.java:278)
jogamp.newt.driver.macosx.WindowDriver.createWindow(WindowDriver.java:777)
jogamp.newt.driver.macosx.WindowDriver.reconfigureWindowImpl(WindowDriver.java:445)
jogamp.newt.driver.macosx.WindowDriver.createNativeImpl(WindowDriver.java:198)
jogamp.newt.WindowImpl.createNative(WindowImpl.java:751)
jogamp.newt.WindowImpl.setVisibleActionImpl(WindowImpl.java:1248)
jogamp.newt.WindowImpl$VisibleAction.run(WindowImpl.java:1318)
com.jogamp.common.util.RunnableTask.run(RunnableTask.java:145)
   - locked java.lang.Object@2dbec237
jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375)

My current understanding of what is going on is the following. It seems that the Swing container where the NewtCanvasAWT is (a JPanel with BorderLayout) sets its bounds (a normal thing for a container) and therefore calls the reshape method. The problem then is that at this moment the window is not visible yet and therefore tries to make it visible. That seems to block maybe because the window was already in the process of being made visible, I'm not sure.

Can you help me clarify what's going on? Much appreciated!
Reply | Threaded
Open this post in threaded view
|

Re: Deadlock with NewtCanvasAWT

gouessej
Administrator
Hi

Do you reproduce this bug with one of our unit tests?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Deadlock with NewtCanvasAWT

mbastian
No, I wasn't able to reproduce it but it happens systematically in my application so there must be a way but given that I don't exactly understand what triggers it I'm not so sure where to start.
Reply | Threaded
Open this post in threaded view
|

Re: Deadlock with NewtCanvasAWT

gouessej
Administrator
I'm sorry but you should really try to write a simple test case to reproduce this bug. If we aren't unable to reproduce this bug, it gives us no chance of helping you.
Julien Gouesse | Personal blog | Website