GUI blocks when calling method on GUI

Hello,

        I have a problem of thread bocking when i call method on GLCanvas object in any thread. 

        I am calling a method like this

                   canvas.getGraphicsConfiguration()
                   canvas.getGraphicsConfiguration().getDevice();

        where canvas is a object of GLCanvas or applet.

        I have tried using intrupt method on the thread but it does not come out from the blocked state.

Thanks and Regards

You can use the “jstack” program that comes with the jdk to get the stack trace of any running JVM. It’ll even find simple deadlocks for you.

Hello,

        i do not find where this program exists and how to use it. The problem what i am facing is when i minimize an browser which contains an applet.

Thanks and Regards

Do those method calls work with a normal Canvas object or a GLJPanel? If they all fail to work and block the thread, it might be that because the applet is minimized, java isn’t able to get the device. Another possibility, is that your permissions aren’t set for an applet to get access to your computers device info.

Hello lhkbob,

           Here, i am pasting a stack trace of delocked threads.

Deadlock found :-
“AWT-EventQueue-2” Id=27 in BLOCKED Time =-1 on lock=java.awt.Component$AWTTreeLock@1f78040
owned by AWT-EventQueue-1 Id=12
at java.awt.Component.getGraphicsConfiguration(Component.java:815)
at com.qedsoft.renderer.abstractfile.renderer.impl.CQ3DRendererOpenGL.makeCurrent(CQ3DRendererOpenGL.java:1341)
at com.qedsoft.renderer.abstractfile.renderer.impl.CQ3DRendererOpenGL.beginRendererContext(CQ3DRendererOpenGL.java:1325)
at com.qedsoft.q3dplayer.extended.impl.CQ3DPlayerExtended.beginRendererContext(CQ3DPlayerExtended.java:114)
at com.qedsoft.realstreamlib.impl.CQ3DRealStream.beginRendererContext(CQ3DRealStream.java:1365)
at com.qedsoft.realstreamlib.impl.QEDThreadPlayer.run(QEDThreadPlayer.java:30)
at com.qedsoft.player.impl.CRealStreamPlayer.display(CRealStreamPlayer.java:111)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:324)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:341)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

“AWT-EventQueue-1” Id=12 in BLOCKED Time =-1 on lock=java.lang.Class@50988
owned by AWT-EventQueue-2 Id=27
at sun.java2d.loops.DrawGlyphListAA.DrawGlyphListAA(Native Method)
at sun.java2d.pipe.AATextRenderer.drawGlyphList(AATextRenderer.java:36)
at sun.java2d.pipe.GlyphListPipe.drawChars(GlyphListPipe.java:85)
at sun.java2d.pipe.ValidatePipe.drawChars(ValidatePipe.java:160)
at sun.java2d.SunGraphics2D.drawChars(SunGraphics2D.java:2720)
at com.sun.java.swing.SwingUtilities2.drawChars(SwingUtilities2.java:609)
at javax.swing.text.Utilities.drawTabbedText(Utilities.java:159)
at javax.swing.text.Utilities.drawTabbedText(Utilities.java:89)
at javax.swing.text.PlainView.drawUnselectedText(PlainView.java:137)
at javax.swing.text.PlainView.drawElement(PlainView.java:96)
at javax.swing.text.PlainView.drawLine(PlainView.java:65)
at javax.swing.text.PlainView.paint(PlainView.java:288)
at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1338)
at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:643)
at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:781)
at javax.swing.plaf.synth.SynthTextAreaUI.paint(SynthTextAreaUI.java:109)
at javax.swing.plaf.synth.SynthTextAreaUI.update(SynthTextAreaUI.java:104)
at javax.swing.JComponent.paintComponent(JComponent.java:743)
at javax.swing.JComponent.paint(JComponent.java:1006)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JViewport.paint(JViewport.java:728)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4979)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
at javax.swing.JComponent.paint(JComponent.java:996)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1709)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.X11.XRepaintArea.paintComponent(XRepaintArea.java:56)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:645)
at java.awt.Component.dispatchEventImpl(Component.java:4044)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Window.dispatchEventImpl(Window.java:1778)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Please let me know if you could find any reason for dead lock.
Deadlock comes only when i switch between any window or minimize and maximize it. I think that it occurs when any GUI event occurs.

Thanks and Regards

   Error is only comming on the linux platform and not on others.

Something very odd going on there - I’ve never seen two simultaneous AWT event threads before ???

Hello bleb,

       I am using an animator class of JOGL. I think that one of the thread is normal awt thread and another one is a thread for animtor.

      In stack trace "[b]AWT-EventQueue-2[/b]" is showing method of my application and "[b]AWT-EventQueue-1[/b]" (Second Stack Trace) is shoowing methods of system related activities.


     I think "AWT-EventQueue-2" (First Stack Trace) is a thread for animator of JOGL.

Thanks and Regards

There are implementation restrictions on what you can do on X11 platforms. JOGL has to obtain a global AWT lock during its rendering phase in order to avoid multithreading problems communicating with the X server. This means that you may not be able to perform the same kinds of AWT operations inside your GLEventListener that you can on Windows. In general I’ve been able to recommend to people to use EventQueue.invokeLater() as a workaround for this. However, your app seems to be doing OpenGL context manipulation from within your GLEventListener callback, which looks to me like a misdesign in your app.