[cairo] Odd bug in 1.5.6, not rendering all of attached Inkscape file

Carl Worth cworth at cworth.org
Tue Jan 22 13:49:39 PST 2008

On Tue, 22 Jan 2008 13:57:13 -0600, Terry Brown wrote:
> For some reason Cairo 1.5.6, as invoked by Inkscape SVN 17155, on
> Ubuntu 7.10, doesn't save all the parts of incomplete_pdf.svg to
> incomplete_pdf.pdf.  The SVG was originally part of a larger file, and
> no layers above the SVG included here are rendered, so cairo is
> aborting rather than skipping the render of just these parts.

OK, this is easy enough to track down. Here's the problematic part of
the SVG file:


That's a transformation matrix that scales to 0 in one dimension. So
the matrix is not invertible. And current versions of cairo get all
worked up when you pass it a matrix like that.

And by "gets all worked up" I mean that it refuses to render anything
else in the current context. The inkscape code should definitely be
checking cairo_status before calling cairo_destroy and if things are
working properly then that will return CAIRO_STATUS_INVALID_MATRIX.
And inkscape should be able to pop up a nice error dialog for that,
(though, as noted below we'll also work on fixing cairo so that this
particular error shouldn't happen if you're just drawing things).

The mozilla folks already ran into this problem and what they do is to
call cairo_matrix_invert before setting any matrix, and then just
skipping the rendering of the corresponding element if that
fails. So similar code in inkscape should allow you to workaround this

Meanwhile, we do already have a note in the cairo TODO file to fix
this. It says:

 • Fix cairo so that a degenerate matrix draws nothing rather than
   triggering an error state. That is: cairo_scale (cr, 0, 0); should
   not cause an error, (though maybe it shouldn't actually draw
   _nothing_ for painting an infinite source pattern---compute the
   average color for a surface-based source pattern perhaps?).

It still would be an error if you set a non-invertible matrix and then
asked for an operation that relied on the inverse matrix somehow,
(such as cairo_device_to_user). We'll have to see how that all plays

And for now, I'll be interested to hear how well your complete
document is rendered if you simply delete this rectangle from your SVG
file, (which by definition isn't drawing anything anyway).

Good luck,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080122/0e7ce266/attachment.pgp 

More information about the cairo mailing list