LWJGL Forum

Archive => Resolved Bugs/RFE => Topic started by: Momoko_Fan on June 09, 2011, 00:00:22

Title: [FIXED] Display.update() when using canvas causes deadlock on Linux
Post by: Momoko_Fan on June 09, 2011, 00:00:22
There's a deadlock happening on Linux when canvas is used
http://jmonkeyengine.org/groups/general-2/forum/topic/deadlock-in-swingcanvastest/#post-129936 (http://jmonkeyengine.org/groups/general-2/forum/topic/deadlock-in-swingcanvastest/#post-129936)

Apparently it is because LinuxDisplay is calling Component.setFocused() outside of the EDT which is not allowed.

From what I see this is a bug in LWJGL, and not jME3, since Display.update() isn't supposed to be used in the EDT. Am I right?
Title: Re: [BUG] Display.update() when using canvas causes deadlock on Linux
Post by: Matzon on June 09, 2011, 05:43:27
This looks like a bug. Have you tried to manually change it, and confirm the deadlock goes away?
Title: Re: [BUG] Display.update() when using canvas causes deadlock on Linux
Post by: kappa on June 09, 2011, 22:53:40
all the setFocusable(boolean) calls in LinuxDisplay now run on the EDT, hopefully this should fix the issue, do try the nightly builds to confirm if it works.
Title: Re: [FIXED] Display.update() when using canvas causes deadlock on Linux
Post by: WindPower on June 20, 2011, 19:44:26
It is not fully fixed :( It hangs at another point now; see the jME thread (http://jmonkeyengine.org/groups/general-2/forum/topic/deadlock-in-swingcanvastest/#post-131591) for the stack trace.
Title: Re: [BUG] Display.update() when using canvas causes deadlock on Linux
Post by: Matzon on June 21, 2011, 04:56:37
since we don't have anything to go by, please consider changing the LWJGL code as appropriate and provide a patch.
Title: Re: [FIXED] Display.update() when using canvas causes deadlock on Linux
Post by: kappa on June 26, 2011, 02:00:38
The relevant focus handling code in LinuxDisplay has been rewritten so this should be fixed properly now. Removed the hacks and all EDT related code, like the calls to Canvas.setFocusable(). As a side effect the focus behaviour for lwjgl applets in the browser on linux should also work much better than before.

Do test nightly builds to see if the deadlock is gone now.
Title: Re: [FIXED] Display.update() when using canvas causes deadlock on Linux
Post by: Axiomatic on October 17, 2011, 14:47:51
Quote from: kappa on June 26, 2011, 02:00:38
The relevant focus handling code in LinuxDisplay has been rewritten so this should be fixed properly now. Removed the hacks and all EDT related code, like the calls to Canvas.setFocusable(). As a side effect the focus behaviour for lwjgl applets in the browser on linux should also work much better than before.

Do test nightly builds to see if the deadlock is gone now.

I am trying to use the current libgdx + TWL + lwjgl (2.7.1) and I get


Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
at java.awt.EventQueue.invokeAndWait(EventQueue.java:1025)
at org.lwjgl.opengl.LinuxDisplay.edtSetCanvasFocus(LinuxDisplay.java:915)
at org.lwjgl.opengl.LinuxDisplay.setFocused(LinuxDisplay.java:905)
at org.lwjgl.opengl.LinuxDisplay.processEvents(LinuxDisplay.java:762)
at org.lwjgl.opengl.LinuxDisplay.update(LinuxDisplay.java:797)
at org.lwjgl.opengl.Display.processMessages(Display.java:634)
at org.lwjgl.opengl.Display.update(Display.java:692)
at org.lwjgl.opengl.Display.update(Display.java:662)
at com.badlogic.gdx.backends.lwjgl.LwjglCanvas$2.run(LwjglCanvas.java:165)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Would you mean that the fix is available only on LWJGL 2.8.x ?
Title: Re: [FIXED] Display.update() when using canvas causes deadlock on Linux
Post by: kappa on October 17, 2011, 15:01:57
Quote from: Axiomatic on October 17, 2011, 14:47:51
Would you mean that the fix is available only on LWJGL 2.8.x ?
yes.