Page 2 of 3

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 12:37
by udo
in my error.log I had some
  • sh: /usr/neato: not found
errors...

this was my mistake... I pointed the paths in config_inc.php to the usr path:

Code: Select all

$g_dot_tool = '/usr/dot';
$g_neato_tool = '/usr/neato';
instead of the bin path (enabled by the symlinks):

Code: Select all

$g_dot_tool = '/bin/dot';
$g_neato_tool = '/bin/neato';
Besides that, no notice, warning or error in my error.log. Unfortunately... :?

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 13:04
by atrol
OK, let's find the difference between our installations.

Which Operating system, PHP version, MantisBT version, GraphViz version do you use?
Is this a fresh installation of MantisBT without any customization like custom functions, plugins and/or changing of any delivereds source code?

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 13:39
by udo
OK. My settings are this:
  • Linux Ubuntu 9.04
  • Apache 2.2.11
  • PHP 5.2.10
  • MantisBT 1.2.3
    + no custom functions -> no custom_functions_inc.php file in mantis web root dir
    + installed plugins (default install): MantisBT Core 1.2.3, MantisBT Formatting 1.0a
    + no source code manipulations

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 14:04
by atrol
Nothing special at first sight,
Post the source code of the generated page

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 14:21
by udo
the "Relationship Graph" relevant code of page
  • /bug_relationship_graph.php?bug_id=7&graph=relation
is this:

Code: Select all

<table class="width100" cellspacing="1"> 

<tr> 
	<!-- Title --> 
	<td class="form-title"> 
		Relationship Graph	</td> 
	<!-- Links --> 
	<td class="right"> 
		<!-- View Issue --> 
		<span class="small"><span class="bracket-link">[&nbsp;<a href="view.php?id=7">View Issue</a>&nbsp;]</span> </span> 
 
		<!-- Relation/Dependency Graph Switch --> 
		<span class="small"> 
<span class="bracket-link">[&nbsp;<a href="bug_relationship_graph.php?bug_id=7&graph=dependency">Dependency Graph</a>&nbsp;]</span> 		</span> 
	</td> 
</tr> 
 
<tr> 
	<!-- Graph --> 
	<td colspan="2"> 
<map name="relationship_graph_map"> 
<area shape="rect" href="bug_relationship_graph.php?bug_id=7&graph=relation" title="[resolved] Issue 7" alt="" coords="7,7,71,31"> 
<area shape="rect" href="bug_relationship_graph.php?bug_id=18&graph=relation" title="[assigned] Issue 18" alt="" coords="103,20,167,44"> 
</map> 
		<div class="center relationship-graph"> 
			<img src="bug_relationship_graph_img.php?bug_id=7&graph=relation&orientation=horizontal"
				border="0" usemap="#relationship_graph_map" /> 
		</div> 
	</td> 
</tr> 
 
<tr> 
	<!-- Legend --> 
	<td colspan="2"> 
		<table class="hide"> 
		<tr> 
			<td class="center"> 
				<img alt="" src="images/rel_related.png" /> 
				related to			</td> 
			<td class="center"> 
				<img alt="" src="images/rel_dependant.png" /> 
				child of			</td> 
			<td class="center"> 
				<img alt="" src="images/rel_duplicate.png" /> 
				duplicate of			</td> 
		</tr> 
		</table> 
	</td> 
</tr>
</table>
Note: I started with the short part. I can still provide the complete page source if needed.

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 16:04
by atrol
To exclude that this is browser related.
Check my test installation
http://62.75.242.233/mantisbt-1.2.3
Broken image or not?

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 16:09
by udo
credentials? :wink: user,pass...

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 17:50
by atrol
You can signup for an account

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 18:07
by udo
:oops: sorry about this...

Works perfectly, I can see the graph here: http://62.75.242.233/mantisbt-1.2.3/bug ... h=relation

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 18:14
by atrol
Do you use Firefox?
If yes, install addon Firebug
This will help you to find the difference between your site and mine
Use "Network" tab of Firebug for examinations

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 19:54
by udo
:idea: OK, found something...

On (my) page
  • MyMantis.tld/bug_relationship_graph.php?bug_id=7&graph=relation
in
  • Firebug > Tab Net > Select Images > Refresh page
I get a 200 OK response for resource
  • MyMantis.tld/bug_relationship_graph_img.php?bug_id=7&graph=relation&orientation=horizontal
but the response (click + then tab Response) is empty... (on your demo server there is the relationship image as response)

So my first guess is that GraphViz is not generating the image...

Now I noticed that I have forget to mention the GraphViz version:

Code: Select all

root@prod:~# dot -V
dot - Graphviz version 2.20.2 (Mon Mar 30 10:11:53 UTC 2009)
Not sure how to proceed from here...

Re: GraphViz - Broken Image

Posted: 27 Sep 2010, 20:27
by atrol
my GraphViz is version 2.26.3
I don't think it's causing the problem, but that's just a feeling.
Another difference on my server is, that I use an older version of PHP (5.1.6)

Since yesterday I am fighting with my environment for PHP 5.2 tests , the VM crashed after an update.
After this is running again, I will try graphs.

Re: GraphViz - Broken Image

Posted: 29 Sep 2010, 08:02
by atrol
Have a look at http://www.mantisbt.org/bugs/view.php?id=12410
This shouldn't solve your problem because you wrote, that you didn't change anyting and don't have any further installed plugin.
But who knows ...

Re: GraphViz - Broken Image

Posted: 29 Sep 2010, 08:30
by Renegade_
lol :lol: I just registered to link this here, since I found this post while searching for solutions before I found the problem.

Since I have just gone through all the funny "let's figure out why graphviz is broken!" stuff and won, I'd be happy to help investigate this issue.

First things first: Grab the URL of your broken graph image and download it manually, for example with wget or curl. Look at it in a hex editor.
If you see text or nothing, then there was nothing actually being generated.
If you see a bunch of gibberish (i.e. binary data), then there's data there, and we'll have to figure out what it is: Check if the bytes 89 50 4E 47 (probably displayed as ".PNG") are at the very beginning, or close to it.
If at the very beginning, then the file at least starts as a proper PNG file, and there must be corruption later on.
If close to the beginning, but not quite, you probably have the same issue I had. See if my patch helps you.
If there's no such value at the beginning, you're getting garbage data, and we'll have to figure out why.

Assuming you either got text/nothing or garbage data, we'll check if graphviz works first:
Assuming you have shell access, save the following code

Code: Select all

digraph G
{
        node [shape = record];

        node0 [ label ="<f0> | <f1> J | <f2> "];
        node1 [ label ="<f0> | <f1> E | <f2> "];
        node4 [ label ="<f0> | <f1> C | <f2> "];
        node6 [ label ="<f0> | <f1> I | <f2> "];
        node2 [ label ="<f0> | <f1> U | <f2> "];
        node5 [ label ="<f0> | <f1> N | <f2> "];
        node9 [ label ="<f0> | <f1> Y | <f2> "];
        node8 [ label ="<f0> | <f1> W | <f2> "];
        node10 [ label ="<f0> | <f1> Z | <f2> "];
        node7 [ label ="<f0> | <f1> A | <f2> "];
        node3 [ label ="<f0> | <f1> G | <f2> "];


        "node0":f0 -> "node1":f1;
        "node0":f2 -> "node2":f1;

        "node1":f0 -> "node4":f1;
        "node1":f2 -> "node6":f1;
        "node4":f0 -> "node7":f1;
        "node4":f2 -> "node3":f1;

        "node2":f0 -> "node5":f1;
        "node2":f2 -> "node9":f1;

        "node9":f0 -> "node8":f1;
        "node9":f2 -> "node10":f1;
}
as a text file (dottest.txt), and try to run graphviz manually with it, like

Code: Select all

dot -Tpng -o dottest.png dottest.txt
see if dottest.png is a proper PNG file. If so, the issue is not with graphviz.
It it's not, try

Code: Select all

dot -Tpng -v
and see what it complains about. It's possible it's simply not compiled with support, or you're lacking a library.

If that succeeded, go into core/graphviz_api.php
and look for

Code: Select all

$t_descriptors = array(
        0 => array(
                'pipe',
                'r',
        ),
        1 => array(
                'pipe',
                'w',
        ),
        2 => array(
                'file',
                'php://stderr',
                'w',
        ),
)
comment it out, and replace it with

Code: Select all

$t_descriptors = array(
    0 => array("pipe", "r"),
    1 => array("file", "/tmp/dot_file.png", "a"),
    2 => array("file", "/tmp/error-output.txt", "a")
)
Warning: On my server, that regularly tried to exceed PHP's memory limits. Make sure you have a sane cutoff in the config, or make sure you have a kill switch at hand before you trigger this.

Once you do run it, you will find out something very important: Whether the issue is with the creation of the image, or with the saving/sending part.
Since the actual graph now bypasses Mantis's processing and sending, simply checking whether /tmp/dot_file.png is a proper graph should tell you whether the graph gets created alright or not.
(Remember to revert the array change once you have a clear result.)

If the graph not being properly created when bypassing Mantis, check /tmp/error-output.txt, and, if that is empty, check if your webserver-user has the proper access rights to graphviz and that kind of stuff.
If the graph is properly being created, the issue is with the saving/outputting and sending of the graph, which will narrow the search down a bit.

As someone who just spent several hours debugging an error like this, rest assured, I know how frustrating it is.
The best thing you can do is systematically rule out error sources and narrow down what and where the actual issue is.
  • Is it in the file?
  • Is it in GraphViz?
  • Is it in PHP or the webserver?
  • Is it in Mantis?
Once you know what you can rule out, it'll be much easier to find the actual source.

Hope this helps a little, and do report back what you find.

Re: GraphViz - Broken Image

Posted: 29 Sep 2010, 09:00
by udo
:D YOU (and Renegade, the patch provider) ARE THE MEN! Big thanks, it works. -> In my opinion, this patch should make it to the new release...

Let's close this thread ;)

Note: If I meet you guys, I buy the beer!