Closed Bug 1762792 Opened 2 years ago Closed 2 years ago

SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element)

Categories

(Core :: SVG, defect)

defect

Tracking

()

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: fmuaddib, Assigned: longsonr)

References

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15

Steps to reproduce:

Just point to this url:

https://is.gd/rtVT8x

This is a svg frme by frame animation (pure SMIL).
Works fine on Chrome and Safari.

I also uploaded it as a gist on Github:
https://gist.github.com/Emasoft/1d87defdf81f9844ad8710e8176b7ec1

Actual results:

Blank page in Firefox (any version).
Works fine on Chrome and Safari.

Expected results:

The looping animation should have been displayed like in the other browsers.

The Bugbug bot thinks this bug should belong to the 'Core::Graphics: WebRender' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Graphics: WebRender
Product: Firefox → Core
Component: Graphics: WebRender → SVG

I think this is because of the width="0px" and height="0px" on the use element. The SVG 2 specification clarifies that these should be ignored if the use element points to something other than a symbol or svg element which is the case here.

Indeed, if you use devtools to remove those width="0px" height="0px" attributes, then the animation plays just fine in Firefox.

The SVG 2 specification clarifies that these should be ignored if the use element points to something other than a symbol or svg element which is the case here.

Sounds like this is indeed a bug, and we should be ignoring those attributes.

Going into a bit more detail: it looks like our behavior (not-rendering the element) comes from the attribute definitions for use in SVG 1.1 here:
https://www.w3.org/TR/SVG11/struct.html#UseElement

 width = "<length>"
     [...] A value of zero disables rendering of the element.

height = "<length>"
     [...] A value of zero disables rendering of the element.

But indeed, SVG2 section https://www.w3.org/TR/SVG2/struct.html#UseElement clarifies this as Robert indicated:

The width and height attributes only have an effect
if the referenced element defines a viewport
(i.e., if it is a ‘svg’ or ‘symbol’);
[...]
If width or height is zero, and the properties have an effect
on the referenced element, then rendering of that element
will be disabled.
Attached file testcase 1 (reduced)

Here's a testcase getting to the root here, with <use> pointing at a rect element, 3 times, with width/height, just width, and just height being set to 0.

In all 3 cases, the use element should render its cloned rect, but Firefox does not render it (due to SVG1.1 spec text quoted above).

Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: svg frame by frame animation not displayed → SVG use elements should ignore zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element)
Version: Firefox 99 → Trunk
Summary: SVG use elements should ignore zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element) → SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element)

In the meantime: if you're running up against this bug in SVG content that you're writing yourself, you can avoid it by simply removing the width and height attributes from the use element.

Per the quoted SVG2 spec text, those attributes are literally defined as having no effect in this case, so there shouldn't be any useful reason to have them there.

Severity: -- → S3

(In reply to Daniel Holbert [:dholbert] from comment #6)

In the meantime: if you're running up against this bug in SVG content that you're writing yourself, you can avoid it by simply removing the width and height attributes from the use element.

Yes, thanks for the suggestion. I will change my code to avoid generating those attributes for the use element.

Assignee: nobody → longsonr
Status: NEW → ASSIGNED
Attachment #9282812 - Attachment description: WIP: Bug 1762792 - SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element) → Bug 1762792 - SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element)
Attachment #9282812 - Attachment description: Bug 1762792 - SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element) → WIP: Bug 1762792 - SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element)
Attachment #9282812 - Attachment description: WIP: Bug 1762792 - SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element) → Bug 1762792 - SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element)
Pushed by longsonr@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/ae6e6b9307a2
SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element) r=emilio
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: