[FIXED] Display.update() when using canvas causes deadlock on Linux

Started by Momoko_Fan, June 09, 2011, 00:00:22

Previous topic - Next topic

Momoko_Fan

There's a deadlock happening on Linux when canvas is used
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?

Matzon

This looks like a bug. Have you tried to manually change it, and confirm the deadlock goes away?

kappa

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.

WindPower

It is not fully fixed :( It hangs at another point now; see the jME thread for the stack trace.

Matzon

since we don't have anything to go by, please consider changing the LWJGL code as appropriate and provide a patch.

kappa

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.

Axiomatic

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 ?

kappa