Closed Bug 1903546 Opened 2 years ago Closed 2 years ago

Wrong non-scaling-stroke rendering in a nested svg

Categories

(Core :: SVG, defect)

Firefox 127
defect

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox-esr128 --- fixed
firefox129 --- fixed
firefox130 --- fixed

People

(Reporter: rayhan.azizi9, Assigned: longsonr)

References

Details

Attachments

(5 files, 1 external file, 1 obsolete file)

Attached image bug.png —

Steps to reproduce:

Render this SVG

    <svg id="svg3" width="300" height="200" style="overflow: visible">
      <svg
        width="100%" height="100%" style="overflow: visible" preserveAspectRatio="xMidYMid meet"
        viewBox="-1.6111111640930176 -1.1111111640930176 3.222222328186035 2.222222328186035"
      >
        <svg overflow="visible" x="0" y="0">
          <polygon
            style=" fill: rgb(199, 199, 199); stroke: black; stroke-width: 1px;
              stroke-linejoin: round; vector-effect: non-scaling-stroke;"
            points="-1.5,1 1.5,1 1.5,-1 -1.5,-1"
          ></polygon>
        </svg>
      </svg>
    </svg>

or the full HTML

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <svg id="svg3" width="300" height="200" style="overflow: visible">
      <svg
        width="100%" height="100%" style="overflow: visible" preserveAspectRatio="xMidYMid meet"
        viewBox="-1.6111111640930176 -1.1111111640930176 3.222222328186035 2.222222328186035"
      >
        <svg overflow="visible" x="0" y="0">
          <polygon
            style=" fill: rgb(199, 199, 199); stroke: black; stroke-width: 1px;
              stroke-linejoin: round; vector-effect: non-scaling-stroke;"
            points="-1.5,1 1.5,1 1.5,-1 -1.5,-1"
          ></polygon>
        </svg>
      </svg>
    </svg>
  </body>
</html>

Actual results:

Starting from version 127 forward, the calculation of polygon stroke with vector-effect: non-scaling-stroke inside the nested SVG is incorrect. The scale is wrong.
I believe because the viewBox attribute is not properly inherited to the inner svg

attached (bug.png)

Expected results:

The scale should be correct. The calculation for the width of the border should follow the viewBox attribute in the parent's parent <svg> element

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
Attached file reporter's testcase —

Please explain with reference to the SVG specification why you think Firefox is incorrect.

Per https://www.w3.org/TR/SVG2/painting.html#non-scaling-stroke

The stroke outline is calculated in the following manner: first, the shape's path is transformed into the host coordinate space. Stroke outline is calculated in the host coordinate space. The resulting outline is transformed back to the user coordinate system.

Note that an <svg> element establishes a new viewport per https://www.w3.org/TR/SVG2/coords.html#EstablishingANewSVGViewport

Flags: needinfo?(rayhan.azizi9)
Severity: -- → S3

Seems like the report here is at the level of svg, not graphics, even if this is not a valid bug that would be a better place. Please revert if I'm mistaken.

Component: Graphics: WebRender → SVG
Attached image comparison.png —

Top

  1. Eye of GNOME 45.3
  2. Brave Browser Version 1.67.119 Chromium: 126.0.6478.114 (Official Build) (64-bit)
  3. Mozilla firefox-127.0.r20240606181944

Bottom
4. GIMP 2.10.38
5. Inkscape 1.2.2 (b0a8486541, 2022-12-01)
6. Canva (as of June 21st 2024)

Flags: needinfo?(rayhan.azizi9)
Attached image test.svg —

I'm not sure if this is an actual bug or not, I can't say that I understand the SVG specification. I just noticed that other software renders it differently

I've attached a screenshot, comparing how other software renders the same SVG file (comparison.png)

  1. Eye of GNOME 45.3
  2. Brave Browser Version 1.67.119 Chromium: 126.0.6478.114 (Official Build) (64-bit)
  3. Mozilla firefox-127.0.r20240606181944
  4. GIMP 2.10.38
  5. Inkscape 1.2.2 (b0a8486541, 2022-12-01)
  6. Canva (as of June 21st 2024)

It might be the case that Firefox is the one that actually correctly follows the specs while the other software doesn't handle this case yet

Should someone file bugs on other browsers and/or land a wpt test?

I guess so, yes.

Duplicate of this bug: 1904785
Attached file testcase with screen —
Assignee: nobody → longsonr
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee: longsonr → nobody
Status: ASSIGNED → NEW
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → INVALID
See Also: → 1904891

It seems that https://github.com/w3c/svgwg/issues/582 supersedes the spec here and so we'll need to revert the viewport/screen support in favour of that interpretation.

Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Assignee: nobody → longsonr
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47097 for changes under testing/web-platform/tests
Status: REOPENED → RESOLVED
Closed: 2 years ago → 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 130 Branch
Upstream PR merged by moz-wptsync-bot

Comment on attachment 9412279 [details]
Bug 1903546 - fix non-scaling-stroke r=emilio

Beta/Release Uplift Approval Request

  • User impact if declined: non-scaling-stroke will be incorrect for nested <svg> elements.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This reverts most of the changes in bug 1904891 which is currently in beta. That bug implements part of the SVG specification that has been superseded and is not compatible with Chrome or Safari. This bug restores that compatibility.
  • String changes made/needed: none
  • Is Android affected?: Yes
Attachment #9412279 - Flags: approval-mozilla-beta?

Comment on attachment 9412279 [details]
Bug 1903546 - fix non-scaling-stroke r=emilio

Approved for 129.0b4

Attachment #9412279 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Regressions: 1910842
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: