UI Thread blocked

I am adding video chat panel which embed a flash in a web browser to the chat room.And I use red5 for flash video/audio server.

It done well except the ui thread blocked sometimes.

Use the jstack to check the EventQueue.May be these are the problem:

“AWT-EventQueue-1” prio=6 tid=0x04471c00 nid=0x13d0 in Object.wait() [0x05b6f000]

java.lang.Thread.State: WAITING (on object monitor)

at java.lang.Object.wait(Native Method)

at java.lang.Object.wait(Object.java:485)

at org.jdesktop.jdic.browser.WebBrowser.waitForResult(Unknown Source)

  • locked <0x28c71c30> (a org.jdesktop.jdic.browser.WebBrowser)

at org.jdesktop.jdic.browser.WebBrowser.getURL(Unknown Source)

at org.jivesoftware.spark.component.browser.NativeBrowserViewer.downloadCompleted( NativeBrowserViewer.java:80)

at org.jdesktop.jdic.browser.WebBrowser.dispatchWebBrowserEvent(Unknown Source)

at org.jdesktop.jdic.browser.internal.NativeEventThread$3.run(Unknown Source)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at org.jivesoftware.sparkimpl.plugin.idle.UserIdlePlugin$2.dispatchEvent(UserIdleP lugin.java:161)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

But I amnot sure about this.Could anybody explain this for me.And help me to resolve this problem?

Thanks in advanced.

Here is the whole jstack log
1.txt.zip (2800 Bytes)

I found another ui blocking caused by idle plugin.

“AWT-EventQueue-1” prio=6 tid=0x047c2400 nid=0xcac waiting for monitor entry [0x03b1f000]

java.lang.Thread.State: BLOCKED (on object monitor)

at java.awt.Component.invalidate(Component.java:2763)

  • waiting to lock <0x27f9d700> (a java.awt.Component$AWTTreeLock)

at java.awt.Container.invalidate(Container.java:1446)

at javax.swing.JComponent.revalidate(JComponent.java:4789)

at javax.swing.plaf.basic.BasicTextUI$RootView.preferenceChanged(BasicTextUI.java: 1394)

at javax.swing.text.View.preferenceChanged(View.java:272)

at javax.swing.text.BoxView.preferenceChanged(BoxView.java:269)

at javax.swing.text.WrappedPlainView$WrappedLine.update(WrappedPlainView.java:721)

at javax.swing.text.WrappedPlainView$WrappedLine.insertUpdate(WrappedPlainView.jav a:710)

at javax.swing.text.WrappedPlainView.insertUpdate(WrappedPlainView.java:457)

at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(BasicTextUI.java:1590)

at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(BasicTextUI.java: 1849)

at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:185)

at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:734)

at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:693)

at javax.swing.text.PlainDocument.insertString(PlainDocument.java:114)

at javax.swing.JTextArea.append(JTextArea.java:470)

at org.jivesoftware.smackx.debugger.EnhancedDebugger$10$1.run(EnhancedDebugger.jav a:416)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)

at org.jivesoftware.sparkimpl.plugin.idle.UserIdlePlugin$2.dispatchEvent(UserIdleP lugin.java:161)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:26 9)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:17 4)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

What version of Spark are you using? The nightly builds have huge code changes (Smack 3.2 trunk is in it since Mar 10, 2011) and any analysis / fix will have to be against this code.

I think maybe it is the jdic’bug.Because in the WebBrowser.getUrl():

public URL getURL() {

eventThread.fireNativeEvent(instanceNum, NativeEventData.EVENT_GETURL);

if (waitForResult() == true) {

try {

return new URL(eventThread.getEventRetString());

} catch (Exception e) {

}

}

return null;

}

and waitForResult method:

private boolean waitForResult() {

if (!isInitialized) {

WebBrowserUtil.trace("You can’t call this method before "

  • “WebBrowser is initialized!”);

return false;

}

boolean ret = false;

synchronized (this) {

try {

wait();

ret = true;

} catch (Exception e) {

System.out.println(e.getMessage());

}

}

return ret;

}

It call wait method.But seems not any place to notify(or maybe in native method?I have no idea with native code,so I am not sure.)

So the NativeBrowserViewer’s downloadCompleted method:

public void downloadCompleted(WebBrowserEvent event) {

if (browser == null || browser.getURL() == null) {

return;

}

String url = browser.getURL().toExternalForm();

documentLoaded(url);

}

invokes getURL two times.which is not to be.

And it cause the ui hang?

We use spark rc1.And we upgrade to smack 3.2 trunk ,too.we have do many custom changes to the spark for our need,so maybe it is hard to follow up to spark trunk.