Skip to main content

SGComponentRepaintManager threading issue

1 reply [Last post]
mortennobel
Offline
Joined: 2004-11-03
Points: 0

Hi

I think I have found a potential deadlock situation in the SGComponentRepaintManager class.

If another thread requests a repaint, then a deadlock is likely to occur (see stack trace below for an example).

I know that Swing isn't threadsafe, but I'm pretty sure that you are allowed to call repaint() from any thread (the article "Painting in AWT and Swing" from java.sun.com states that "[The repaint manager] uses invokeLater() to process the pending requests on the event dispatching thread, as described in the section on "Repaint Processing" (option B).". The SGComponentRepaintManager calls repaint directly.

Kind regards,
Morten

"Attachment" (Deadlock):

Thread-4@490, priority=4, in group 'file:/Local/Temp/-threadGroup', status: 'MONITOR'
blocks AWT-EventQueue-2@58d
waiting for AWT-EventQueue-2@58d
at com.sun.scenario.scenegraph.SGEventQueue.setAnimationRunnable(SGEventQueue.java:484)
at com.sun.scenario.scenegraph.SwingGlueLayer.setAnimationRunnable(SwingGlueLayer.java:87)
at com.sun.scenario.animation.MasterTimer$MainLoop.updateAnimationRunnable(MasterTimer.java:304)
at com.sun.scenario.animation.MasterTimer$MainLoop.setJobsReady(MasterTimer.java:295)
at com.sun.scenario.animation.MasterTimer.notifyJobsReady(MasterTimer.java:238)
at com.sun.scenario.animation.FrameJob.wakeUp(FrameJob.java:34)
at com.sun.scenario.scenegraph.JSGPanelRepainter.addDirtyPanel(JSGPanelRepainter.java:58)
at com.sun.scenario.scenegraph.JSGPanel.markDirty(JSGPanel.java:621)
at com.sun.scenario.scenegraph.SGNode.markParentsDirty(SGNode.java:550)
at com.sun.scenario.scenegraph.SGNode.visualChanged(SGNode.java:565)
at com.sun.scenario.scenegraph.SGLeaf.repaint(SGLeaf.java:122)
at com.sun.scenario.scenegraph.SGComponent$SGShell.repaint(SGComponent.java:320)
at java.awt.Component.repaint(Component.java:2.790)
at com.sun.scenario.scenegraph.SGComponentRepaintManager.addDirtyRegion(SGComponentRepaintManager.java:64)
at javax.swing.JComponent.repaint(JComponent.java:4.527)
at java.awt.Component.repaint(Component.java:2.747)

AWT-EventQueue-2@58d, priority=4, in group 'file:/Local/Temp/-threadGroup', status: 'MONITOR'
blocks Thread-4@490
waiting for Thread-4@490
at com.sun.scenario.animation.MasterTimer$MainLoop.setJobsReady(MasterTimer.java:293)
at com.sun.scenario.animation.MasterTimer.timePulse(MasterTimer.java:354)
at com.sun.scenario.animation.MasterTimer$MainLoop.run(MasterTimer.java:264)
at com.sun.scenario.scenegraph.SGEventQueue.doPulse(SGEventQueue.java:475)
at com.sun.scenario.scenegraph.SGEventQueue.access$000(SGEventQueue.java:65)
at com.sun.scenario.scenegraph.SGEventQueue$2.run(SGEventQueue.java:382)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.sun.scenario.scenegraph.SGEventQueue.dispatchEvent(SGEventQueue.java:374)
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)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
idk
Offline
Joined: 2005-01-12
Points: 0

Hi,

> If another thread requests a repaint, then a deadlock is likely to occur (see stack trace
below for an example).

I agree. The fix for this problem is checked into the repository (r224)

Thanks,
Igor