graphstream / gs-core

Graphstream core
http://graphstream-project.org/
Other
398 stars 109 forks source link

viewer crash when updating graph #106

Open jgignoux opened 10 years ago

jgignoux commented 10 years ago

I've embbeded GraphStream into another application using graphs. This application (a simulator) generates and deletes nodes and edges according to some internal process. We use graphstream to display the graph in real time. For some reason, the display crashes after some time, generating this error message:

Exception in thread "AWT-EventQueue-3" java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:810) at java.util.HashMap$ValueIterator.next(HashMap.java:839) at org.graphstream.ui.graphicGraph.StyleGroup$BulkIterator.next(StyleGroup.java:816) at org.graphstream.ui.graphicGraph.StyleGroup$BulkIterator.next(StyleGroup.java:773) at scala.collection.convert.Wrappers$JIteratorWrapper.next(Wrappers.scala:42) at scala.collection.Iterator$class.foreach(Iterator.scala:727) at scala.collection.AbstractIterator.foreach(Iterator.scala:1156) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at org.graphstream.ui.j2dviewer.renderer.StyleRenderer.render(StyleRenderer.scala:97) at org.graphstream.ui.j2dviewer.renderer.StyleRenderer.render(StyleRenderer.scala:73) at org.graphstream.ui.j2dviewer.J2DGraphRenderer$$anonfun$render$2$$anonfun$apply$1.apply(J2DGraphRenderer.scala:223) at org.graphstream.ui.j2dviewer.J2DGraphRenderer$$anonfun$render$2$$anonfun$apply$1.apply(J2DGraphRenderer.scala:221) at scala.collection.Iterator$class.foreach(Iterator.scala:727) at scala.collection.AbstractIterator.foreach(Iterator.scala:1156) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at org.graphstream.ui.j2dviewer.J2DGraphRenderer$$anonfun$render$2.apply(J2DGraphRenderer.scala:221) at org.graphstream.ui.j2dviewer.J2DGraphRenderer$$anonfun$render$2.apply(J2DGraphRenderer.scala:220) at scala.collection.Iterator$class.foreach(Iterator.scala:727) at scala.collection.AbstractIterator.foreach(Iterator.scala:1156) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at org.graphstream.ui.j2dviewer.J2DGraphRenderer.render(J2DGraphRenderer.scala:220) at org.graphstream.ui.swingViewer.DefaultView.render(DefaultView.java:237) at org.graphstream.ui.swingViewer.DefaultView.paintComponent(DefaultView.java:172) at javax.swing.JComponent.paint(JComponent.java:1029) at javax.swing.JComponent.paintChildren(JComponent.java:866) at javax.swing.JComponent.paint(JComponent.java:1038) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5138) at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:302) at javax.swing.RepaintManager.paint(RepaintManager.java:1216) at javax.swing.JComponent._paintImmediately(JComponent.java:5086) at javax.swing.JComponent.paintImmediately(JComponent.java:4896) at javax.swing.RepaintManager$3.run(RepaintManager.java:807) at javax.swing.RepaintManager$3.run(RepaintManager.java:795) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:795) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:764) at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:706) at javax.swing.RepaintManager.access$1000(RepaintManager.java:61) at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:673) at java.awt.EventQueue.access$300(EventQueue.java:96) at java.awt.EventQueue$2.run(EventQueue.java:634) at java.awt.EventQueue$2.run(EventQueue.java:632) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108) at java.awt.EventQueue.dispatchEvent(EventQueue.java:643) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177) at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

Since there is no mention in this output of my own code, I wonder whether this is a known Graphstream bug or a problem with my setup of Graphstream inside my application ? I am using the J2DGraphRenderer: System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); and have launched my viewer using ThreadingModel.GRAPH_IN_ANOTHER_THREAD

Any hint of what may be happening ?

thank you. JG

Sanch0ous commented 10 years ago

I have the same problem, did you fix it ?

jgignoux commented 10 years ago

No, unfortunately.

it seems this has to do with graphstream receiving too many update messages and getting unable to process them all. Or simply, one of the data structures is not protected through syncrhonized and the many calls cause the crash...

Dont know really.

Maybe we should hassle the graphstream people a bit more...

Le 15/05/2014 15:04, ProTracker a écrit :

I have the same problem, did you fix it ?

— Reply to this email directly or view it on GitHub https://github.com/graphstream/gs-core/issues/106#issuecomment-43206210.

Jacques Gignoux

sbalev commented 10 years ago

Yes, looks like someone modifies a hashmap while someone else iterates over it. This kind of bug is difficult to reproduce. Could you guys give some more details on how the crash happens? Does it happen with both renderers? Ideally, can you provide some minimal code reproducing the crash?

Thanks for your help, Stefan

Sanch0ous commented 10 years ago

For me, I produce "DGS lines" on a server, and I send each of them gradually to a client with Graphstream. Between each line, there is a 100ms sleep.

Here my DGS lines received and handled by the client (extracted from my logs, so you can see the exception) :

cg stylesheet="graph{fill-color: #FFF, #BBB; fill-mode: gradient-radial;}" an 1_1_1 ui.label=1 layout.weight=5 ui.style="size: 5px; shape: circle; fill-color: red; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right;text-size: 12; " an 101_2_13 ui.label=101 layout.weight=1 ui.style="size: 5px; shape: diamond; fill-color: blue; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right; text-style: bold;text-size: 12; text-color: blue;" ae 1_1_1-101_2_13 1_1_1 101_2_13 ui.style="shape: blob; size: 1px;" an 11_3_14 ui.label=11 layout.weight=5 ui.style="size: 5px; shape: cross; fill-color: red; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right;text-size: 12; " ae 101_2_13-11_3_14 101_2_13 11_3_14 ui.style="shape: blob; size: 1px;" cn 1_1_1 ui.label=1 layout.weight=5 ui.style="size: 5px; shape: circle; fill-color: red; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right;text-size: 12; " cn 101_2_13 ui.label=101 layout.weight=1 ui.style="size: 5px; shape: diamond; fill-color: blue; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right; text-style: bold;text-size: 12; text-color: blue;" ce 1_1_1-101_2_13 ui.style="shape: blob; size: 1px;" cn 11_3_14 ui.label=11 layout.weight=5 ui.style="size: 5px; shape: cross; fill-color: red; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right;text-size: 12; " ce 101_2_13-11_3_14 ui.style="shape: blob; size: 1px;" cn 1_1_1 ui.label=1 layout.weight=5 ui.style="size: 5px; shape: circle; fill-color: red; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right;text-size: 12; " cn 101_2_13 ui.label=101 layout.weight=1 ui.style="size: 5px; shape: diamond; fill-color: blue; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right; text-style: bold;text-size: 12; text-color: blue;" ce 1_1_1-101_2_13 ui.style="shape: blob; size: 1px;" an 102_3_19 ui.label=102 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: blue; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right;text-size: 12; " ae 101_2_13-102_3_19 101_2_13 102_3_19 ui.style="shape: blob; size: 1px;" an 201_4_20 ui.label=201 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: green; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right;text-size: 12; " ae 102_3_19-201_4_20 102_3_19 201_4_20 ui.style="shape: blob; size: 1px;" an 11_5_23 ui.label=11 layout.weight=5 ui.style="size: 5px; shape: cross; fill-color: red; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 201_4_20-11_5_23 201_4_20 11_5_23 ui.style="shape: blob; size: 1px;" cn 1_1_1 ui.label=1 layout.weight=5 ui.style="size: 5px; shape: circle; fill-color: red; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right;text-size: 12; " an 116_2_28 ui.label=116 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: blue; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 1_1_1-116_2_28 1_1_1 116_2_28 layout.weight=1 ui.style="shape: blob; size: 1px;" an 127_3_29 ui.label=127 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: blue; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 116_2_28-127_3_29 116_2_28 127_3_29 layout.weight=1 ui.style="shape: blob; size: 1px;" an 11_4_30 ui.label=11 layout.weight=5 ui.style="size: 5px; shape: cross; fill-color: red; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 127_3_29-11_4_30 127_3_29 11_4_30 layout.weight=1 ui.style="shape: blob; size: 1px;" cn 1_1_1 ui.label=1 layout.weight=5 ui.style="size: 5px; shape: diamond; fill-color: red; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right; text-style: bold;text-size: 12; text-color: red;" cn 101_2_13 ui.label=101 layout.weight=1 ui.style="size: 5px; shape: diamond; fill-color: blue; stroke-mode: plain; padding: 3px, 2px; text-alignment: at-right; text-style: bold;text-size: 12; text-color: blue;" ce 1_1_1-101_2_13 ui.style="shape: blob; size: 1px;" an 110_3_31 ui.label=110 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: blue; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 101_2_13-110_3_31 101_2_13 110_3_31 layout.weight=1 ui.style="shape: blob; size: 1px;" an 204_4_32 ui.label=204 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: green; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 110_3_31-204_4_32 110_3_31 204_4_32 layout.weight=1 ui.style="shape: blob; size: 1px;" an 112_5_33 ui.label=112 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: blue; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 204_4_32-112_5_33 204_4_32 112_5_33 ui.style="shape: blob; size: 1px;" an 204_6_34 ui.label=204 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: green; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 112_5_33-204_6_34 112_5_33 204_6_34 layout.weight=1 ui.style="shape: blob; size: 1px;" an 113_7_35 ui.label=113 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: blue; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 204_6_34-113_7_35 204_6_34 113_7_35 ui.style="shape: blob; size: 1px;" an 204_8_36 ui.label=204 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: green; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 113_7_35-204_8_36 113_7_35 204_8_36 layout.weight=1 ui.style="shape: blob; size: 1px;" an 207_9_37 ui.label=207 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: green; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 204_8_36-207_9_37 204_8_36 207_9_37 ui.style="shape: blob; size: 1px;" an 207_10_38 ui.label=207 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: green; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 207_9_37-207_10_38 207_9_37 207_10_38 ui.style="shape: blob; size: 1px;" an 207_11_39 ui.label=207 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: green; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 207_10_38-207_11_39 207_10_38 207_11_39 ui.style="shape: blob; size: 1px;" an 214_12_40 ui.label=214 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: green; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 207_11_39-214_12_40 207_11_39 214_12_40 ui.style="shape: blob; size: 1px;" Exception in thread "AWT-EventQueue-2" java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(Unknown Source) at java.util.HashMap$KeyIterator.next(Unknown Source) at scala.collection.convert.Wrappers$JIteratorWrapper.next(Wrappers.scala:42) at scala.collection.Iterator$class.foreach(Iterator.scala:727) at scala.collection.AbstractIterator.foreach(Iterator.scala:1157) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at org.graphstream.ui.j2dviewer.J2DGraphRenderer$$anonfun$render$2.apply(J2DGraphRenderer.scala:221) at org.graphstream.ui.j2dviewer.J2DGraphRenderer$$anonfun$render$2.apply(J2DGraphRenderer.scala:220) at scala.collection.Iterator$class.foreach(Iterator.scala:727) at scala.collection.AbstractIterator.foreach(Iterator.scala:1157) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at org.graphstream.ui.j2dviewer.J2DGraphRenderer.render(J2DGraphRenderer.scala:220) at org.graphstream.ui.swingViewer.DefaultView.render(DefaultView.java:238) at org.graphstream.ui.swingViewer.DefaultView.paintComponent(DefaultView.java:172) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintToOffscreen(Unknown Source) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source) at javax.swing.RepaintManager$PaintManager.paint(Unknown Source) at javax.swing.RepaintManager.paint(Unknown Source) at javax.swing.JComponent._paintImmediately(Unknown Source) at javax.swing.JComponent.paintImmediately(Unknown Source) at javax.swing.RepaintManager$3.run(Unknown Source) at javax.swing.RepaintManager$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.access$1100(Unknown Source) at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) 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) an 214_13_41 ui.label=214 layout.weight=1 ui.style="size: 5px; shape: circle; fill-color: green; text-alignment: at-right; stroke-mode: plain; padding: 3px, 2px; text-size: 10;" ae 214_12_40-214_13_41 214_12_40 214_13_41 ui.style="shape: blob; size: 1px;"

Note that the client continue to handle DGS Lines et draw them. My client is an Applet run on Chrome.

Sanch0ous commented 10 years ago

I have another problem, and I don't know if it related to it. At one moment, the graph stop adding new elements and disable the automatic layout. This happens randomly, but always after the error of this post appeared (one or more times).

Sanch0ous commented 10 years ago

SOLVED for me. The problem came from the Java Applet client, but I don't know why. If my client is a .jar executable, problem does not appear.

EDIT : I found the problem. When you use an external Viewer, the problem appear. Here's my code :

System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); Viewer viewer = new Viewer(this.g, Viewer.ThreadingModel.GRAPH_IN_SWING_THREAD); viewer.enableAutoLayout(); View view = viewer.addDefaultView(true);

And when you just use "graph.display()", everything works perfectly.