Bug 2930

Summary: pygoocanvas package missing in Ubuntu 18.04
Product: ns-3 Reporter: Tom Henderson <tomh>
Component: visualizerAssignee: Gustavo J. A. M. Carneiro <gjcarneiro>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, pdbarnes, smith84, tommaso.pecorella
Priority: P3    
Version: unspecified   
Hardware: All   
OS: All   
Attachments: pyviz update bundle

Description Tom Henderson 2018-06-18 10:01:27 EDT
python-pygoocanvas is a dependency of pyviz but has been unmaintained since 2010, and in Ubuntu 18.04, the package was dropped.  Other solutions should be tested and documented for Ubuntu 18.04, such as possibly installing from another PPA or pip, or else building from source.

Longer term, porting pyviz to some other package would help.
Comment 1 Tommaso Pecorella 2018-06-22 08:52:25 EDT
As far as I understand, GooCanvas itself is no more actively developed.
However, GooCanvas (https://github.com/GNOME/goocanvas) seems to have Python bindings.

Perhaps, a good option could be a simple forward-port to "plain" GooCanvas.
Comment 2 Gustavo J. A. M. Carneiro 2018-06-22 09:52:54 EDT
I seem to remember sending somewhere (maybe privately to Tom?) a patch porting from pygoocanvas to pygobject 3.0 based bindings (which work with a system called GObject Introspection, so there are no python bindings specific for GooCanvas, they're not needed anymore).

Ah, there it is... Tom, can you search for "State of ns3 in the Debian distribution" emails?  I sent a hg bundle with my latest work on this.  Can't promise it to be 100% bug free, but it seemed to mostly work, last I checked.

I'll attach the bundle here so it doesn't get lost.
Comment 3 Gustavo J. A. M. Carneiro 2018-06-22 09:53:23 EDT
Created attachment 3116 [details]
pyviz update bundle
Comment 4 Tom Henderson 2018-07-22 11:37:18 EDT
I applied and tested Gustavo's patches and they nearly work, but a lingering issue is that one of the plugins depends on python-kiwi which does not appear to be compatible with GTK3+.

The plugin is src/visualizer/visualizer/plugins/show_last_packets.py.

One possibility is to change the plugin to avoid the dependency.

I established a testing branch with these patches at:

https://gitlab.com/tomhenderson/ns-3-dev/tree/gtk3

For Mint 19/Ubuntu 18.04, I installed the following prerequisites:

  python-gi python-gi-cairo python-pygraphviz python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython ipython3

Ankit said that he would take a look at it.
Comment 5 Tom Henderson 2018-08-08 15:11:00 EDT
I made some progress on debugging this.

First, the required list of packages (Mint 19/Ubuntu 18.04) is:

gir1.2-goocanvas-2.0 python-gi python-gi-cairo python-pygraphviz python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython ipython3

My tree is at:  https://gitlab.com/tomhenderson/ns-3-dev/tree/gtk3

There is a dependency on python-kiwi in the show_last_packets.py plugin, but this plugin seems to be nowhere used, so I think we can ignore it for the moment.

I am able to get this to run successfully except for one feature:

$ ./waf --pyrun src/flow-monitor/examples/wifi-olsr-flowmon.py --vis

The one missing feature is that the flow labels do not show up with the arrows that show flow activity.

The code that is doing this is in core.py, around line 1300.

If I make this change (to lower the visibility threshold):

diff --git a/src/visualizer/visualizer/core.py b/src/visualizer/visualizer/core.py
index 6cc61b9e9..4cd4480e6 100644
--- a/src/visualizer/visualizer/core.py
+++ b/src/visualizer/visualizer/core.py
@@ -1308,7 +1308,7 @@ class Visualizer(GObject.GObject):
 
             kbps = float(rx_bytes*8)/1e3/rx_count/self.sample_period
             label.set_properties(visibility=GooCanvas.CanvasItemVisibility.VISIBLE_ABOVE_THRESHOLD,
-                                 visibility_threshold=0.5,
+                                 visibility_threshold=0.0,
                                  font=("Sans Serif %f" % int(1+BITRATE_FONT_SIZE*k)))
             angle = math.atan2((pos2_y - pos1_y), (pos2_x - pos1_x))
             if -PI_OVER_2 <= angle <= PI_OVER_2:


Then the labels appear.  However, they are all overlaid on a single spot-- the code to align each label with its respective arrow is not working yet.
Comment 6 Tom Henderson 2018-08-12 20:06:08 EDT
Added Gustavo's latest patch to my gitlab branch; works for Ubuntu 18.04/Mint 19.

There is an upstream bug in PyGObject that prevents the flow labels from being rendered vertically:  https://gitlab.gnome.org/GNOME/pygobject/issues/16

Gustavo committed a workaround on it.

On Fedora 26, I am seeing this error:

core.py", line 419, in set_position
    bounds = self.visualizer.canvas.get_bounds()
TypeError: GooCanvas.Canvas.get_bounds() takes exactly 5 arguments (1 given)
Comment 7 Tom Henderson 2018-08-15 16:50:56 EDT
patches committed in changesets 13738 through 13743, and open issues are moved to separate issues (2969-2972).