Swing+JME application hangs with LWJGL, AWT-EventQueue and AWT-Windows threads invoking some window focus methods

Hello!

I have an Swing application with embedded jme panel according to http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:swing_canvas .
Sometimes while flying around the scene my application freezes: windows OS shows me an “Java(TE) Platform SE binary is not responding” window.
I got an threads dump. All threads are "waitng, “sleeping” or “socket operation”, except 3: AWT-EventQueue and LWJGL thread are “running” and AWT-Windows is “waiting for monitor entry”. Here is its stack traces:

"AWT-EventQueue-0@2291" prio=6 tid=0x16 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
	  at sun.awt.windows.WComponentPeer._requestFocus(WComponentPeer.java:-1)
	  at sun.awt.windows.WComponentPeer.requestFocus(WComponentPeer.java:623)
	  at java.awt.Component.requestFocusHelper(Component.java:7447)
	  at java.awt.Component.requestFocusHelper(Component.java:7400)
	  at java.awt.Component.requestFocus(Component.java:7208)
	  at org.lwjgl.opengl.WindowsDisplay$1.run(WindowsDisplay.java:384)
	  at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	  at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:646)
	  at java.awt.EventQueue.access$000(EventQueue.java:84)
	  at java.awt.EventQueue$1.run(EventQueue.java:607)
	  at java.awt.EventQueue$1.run(EventQueue.java:605)
	  at java.security.AccessController.doPrivileged(AccessController.java:-1)
	  at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	  at java.awt.EventQueue.dispatchEvent(EventQueue.java:616)
	  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)

"LWJGL Renderer Thread@6661" prio=6 tid=0x50 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
	 blocks AWT-Windows@957
	  at sun.awt.KeyboardFocusManagerPeerImpl.getNativeFocusedWindow(KeyboardFocusManagerPeerImpl.java:-1)
	  at sun.awt.KeyboardFocusManagerPeerImpl.getCurrentFocusedWindow(KeyboardFocusManagerPeerImpl.java:27)
	  at java.awt.KeyboardFocusManager.getNativeFocusedWindow(KeyboardFocusManager.java:566)
	  at java.awt.KeyboardFocusManager.markClearGlobalFocusOwner(KeyboardFocusManager.java:2508)
	  - locked <0x1e4f> (a java.util.LinkedList)
	  at java.awt.KeyboardFocusManager._clearGlobalFocusOwner(KeyboardFocusManager.java:549)
	  at java.awt.KeyboardFocusManager.clearGlobalFocusOwner(KeyboardFocusManager.java:545)
	  at org.lwjgl.opengl.WindowsDisplay.update(WindowsDisplay.java:527)
	  at org.lwjgl.opengl.Display.processMessages(Display.java:600)
	  - locked <0x1e50> (a java.lang.Object)
	  at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:181)
	  at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:229)
	  at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
	  at java.lang.Thread.run(Thread.java:662)

"AWT-Windows@957" daemon prio=6 tid=0xf nid=NA waiting for monitor entry
  java.lang.Thread.State: BLOCKED
	 waiting for LWJGL Renderer Thread@6661 to release lock on <0x1e4f> (a java.util.LinkedList)
	  at java.awt.KeyboardFocusManager.shouldNativelyFocusHeavyweight(KeyboardFocusManager.java:2316)
	  at sun.awt.windows.WToolkit.eventLoop(WToolkit.java:-1)
	  at sun.awt.windows.WToolkit.run(WToolkit.java:293)
	  at java.lang.Thread.run(Thread.java:662)

I’ve wait for a long and nothing changes.
My OS: Windows 7
Java version: Oracle JDK 1.6.0u30-x64. And I could not change it (
JME version: 3.0.5

Hi

Where is your code? Do you reproduce this bug with a simple example like TestCanvas? Have you ever tested with another renderer? (see AppSettings.setRenderer(String)). Please use a more recent version of Java instead of claiming that you couldn’t change it, it would help to guess whether your bug has something to do with the JRE.

That’s a big project, what part of code would be helpful?
I’ve got this bug twice and could not reproduce it permanently. I’ve tried to find what leads to that with no success so far.
Of course, I could try any JRE version, but finally I should get it working stable on Oracle JDK 1.6.0u30-x64, that’s project requirement and, unfortunately, I could not affect on that.

Yes, but if you try it with a more recent java and it does not crash, we could narrow it down to change or new feature in the newer jre, and maybe try to work around it.

If we can’t reproduce your bug, we can’t fix it. Please provide a SSCCE to reproduce it. I agree with 8Keep123, testing with a more recent JRE would help to determine whether it’s the culprit… and testing with another renderer would help to determine whether the problem comes from the renderer you’re using and/or the set of bindings on which it is based.

How do you expect us to help you if you are reluctant to provide a small reproducer? A stack trace isn’t enough.

Just in case, can you include the stack traces for all of the threads and not just the ones you suspect might be relevant?

I’ll try to find a way to reproduce hang and will include all stack traces.