SVG masks fail to render (or even display)
Open, NormalPublic

Description

Author: kelvinsong10

Description:
Test file

Any SVG element that has an SVG mask will disappear silently.

See https://commons.wikimedia.org/wiki/File:SVG_mask.svg for an example—there should be a pink rectangle with an opacity gradient (not a square, not a solid color, and certainly not nothing at all). Try viewing in Inkscape or Firefox to see the correct version.

Only older revision of the file above apply:
https://upload.wikimedia.org/wikipedia/commons/archive/7/76/20130908193536!SVG_mask.svg
https://upload.wikimedia.org/wikipedia/commons/archive/7/76/20130908193018%21SVG_mask.svg


Version: unspecified
Severity: normal

Attached: mask.svg

Details

Reference
bz53899
bzimport set Reference to bz53899.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Sep 8 2013, 1:54 AM

Upstream issue with rsvg

Thats not true, RSVG supports simple mask fully. Mask with gradients only partialy. For example https://commons.wikimedia.org/wiki/File:SVG_mask_gradient_bug.svg

kelvinsong10 wrote:

So, the same thing that can be achieved with Clipping paths. The whole point of masks is so you can apply opacity gradients/blurs!!! As it stands, the RSVG-supported masks are useless.

I removed the maskUnits="userSpaceOnUse" (in the mask tag) and the mask is working for this file!?

W3C cite: "If attribute ‘maskUnits’ is not specified, then the effect is as if a value of 'objectBoundingBox' were specified."

kelvinsong10 wrote:

Okay, I tried what you did, and it works!!! (The reason I reverted you at the file is because you didn't fix the mask—you flattened the masks and applied the opacity gradient directly to the pink rectangle). Sounds like an Inkscape bug then, as mask behavior doesn't seem to be seriously affected by removal of this property.

(In reply to comment #5)

Sounds like an Inkscape bug then

In that case, upstreaming it with a testcase would be welcome:
http://inkscape.org/report_bugs.php

Created attachment 13260
The original test case with default attributes filled in

In that case, upstreaming it with a testcase would be welcome:
http://inkscape.org/report_bugs.php

Re-opening. maskUnits is part of the spec, the fact its broken in rsvg is a bug in rsvg.

The fact that in this particular svg, the unit types in use don't make much of a difference doesn't mean this isn't a bug.

It appears rsvg does not have the correct defaults for the x, y, width and height attribute on <mask> when using userSpaceOnUse. According to the spec, I believe the correct defaults are -10%, -10%, 120%, 120% respectively. [1] (Assuming I interpreted spec correctly. I'm not really all that familiar with the details of the svg spec)

Attaching an svg with these defaults filled in, appears to make the file work fine for rsvg.

[1] http://www.w3.org/TR/SVG11/masking.html#MaskElementMaskUnitsAttribute

Attached: maskFixed.svg

(In reply to comment #7)

It appears rsvg does not have the correct defaults for the x, y, width and
height attribute on <mask> when using userSpaceOnUse. According to the spec,
I
believe the correct defaults are -10%, -10%, 120%, 120% respectively. [1]
(Assuming I interpreted spec correctly. I'm not really all that familiar with
the details of the svg spec)

I have a 4 line patch to rsvg that I think fixes the issue (Think being the operative word. I'm a c newb). I just spent 4 hours trying to make the thing compile at all, so I'm going to sleep on it, and then test it a bunch to make sure it actually works like I think it does. If so I'll file a bug/patch upstream and see what happens.

(In reply to comment #9)

I have a 4 line patch to rsvg that I think fixes the issue (Think being the
operative word. I'm a c newb). I just spent 4 hours trying to make the thing
compile at all, so I'm going to sleep on it, and then test it a bunch to make
sure it actually works like I think it does. If so I'll file a bug/patch
upstream and see what happens.

bawolff: Did you have time for that? Is there an upstream URL?

(In reply to comment #10)

(In reply to comment #9)
> I have a 4 line patch to rsvg that I think fixes the issue (Think being the
> operative word. I'm a c newb). I just spent 4 hours trying to make the thing
> compile at all, so I'm going to sleep on it, and then test it a bunch to make
> sure it actually works like I think it does. If so I'll file a bug/patch
> upstream and see what happens.

bawolff: Did you have time for that? Is there an upstream URL?

Sorry not yet. Ill try to do that soon. My free time to do wiki stuff has somewhat evaporated.

bawolff: Understanding that you're busy, could you please share your untested four lines here so someone else would have the chance to test / improve a potential patch?

Created attachment 13897
patch to librsvg to change default mask size

(In reply to comment #12)

bawolff: Understanding that you're busy, could you please share your untested
four lines here so someone else would have the chance to test / improve a
potential patch?

Sorry, I meant to get back to this bug way before now, but I kind of forgot about this.

See the relavent section of the svg spec for where the numbers I chose came from.

Before submitting this upstream, I wanted to compile the patch on rsvg master (I was having trouble generating the build script, although I haven't put much effort into that. I did test on a modified version of the librsvg-2.39.0 tarball and it seemed to work well).

I also wanted to create a minimal test case for this before submitting upstream, which I haven't gotten around to yet.

Attached: file_53899.txt

How does this relate to T8250?

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 19 2015, 6:55 PM
Menner added a subscriber: Menner.Oct 15 2015, 4:36 PM
Menner edited the task description. (Show Details)Oct 15 2015, 5:02 PM
Menner set Security to None.
Menner edited the task description. (Show Details)

I've created a category to make it easier to find examples where mask rendering fails.

Add Comment