Skip to content

Support a subset of SVG #12973

Closed
Closed

Description

@jdm

We need to start experimenting with SVG support in order to have more confidence in using WebRender for Gecko. This issue will serve as a tracking metabug for that work. Our goal is to implement the smallest subset possible, such that particular testcases look correct. We should hide this behind feature flags to avoid exposing a half-baked SVG implementation to web content.

Activity

  1. added
    B-meta
    on Aug 22, 2016
  2. jdm commented on Aug 22, 2016

    @jdm
    MemberAuthor
  3. jdm commented on Aug 22, 2016

    @jdm
    MemberAuthor

    I am working from the assumption that https://www.w3.org/TR/SVG11/ is the specification to care about at this point.

  4. larsbergstrom commented on Aug 22, 2016

    @larsbergstrom
    Contributor
  5. jdm commented on Aug 22, 2016

    @jdm
    MemberAuthor

    @nical's renderer is part of the work. I'm filing issues for the DOM and layout infrastructure surrounding that which will allow us to run representative benchmarks.

  6. metajack commented on Aug 22, 2016

    @metajack
    Collaborator

    @SimonSapin has a parser already working that he was using for some experiments.

  7. SimonSapin commented on Aug 22, 2016

    @SimonSapin
    Member

    I have a a parser for the micro-syntax of d attributes of SVG <path> elements that I put together with an existing XML parser and just enough hard-coded glue to render one carefully chosen example file :) https://github.com/SimonSapin/victor

    I have written https://github.com/SimonSapin/victor/blob/master/src/svg/README.md about the state of SVG specifications as of a couple months ago.

    Last time I discussed this with Jack we talked about using moz2d to render SVG to a pixel buffer, and give that to WebRender to treat as an image. I’m not sure how this would help with confidence in WebRender.

    @pcwalton, @glennw, my understanding is that WebRender’s strategy is to not support arbitrary 2D graphics but specialize in CSS things like axis-aligned rectangles with rounded corners. Has that changed? (That is, would you want WebRender to support enough primitives to render SVG without something like moz2d?) Or more generally, what do you think is a good strategy to implement SVG in a browser that uses WebRender?

  8. SimonSapin commented on Aug 22, 2016

    @SimonSapin
    Member

    pcwalton> just render it to a canvas, basically like today
    pcwalton> I mean
    pcwalton> not a true
    pcwalton> but something like that
    gw> SimonSapin: I think (without having read the entire spec) that doing native svg in wr is quite doable, and probably a sensible (long term) goal. Certainly writing to a canvas with moz2d is the easiest way to get a reasonable feature set working in a short-ish time frame. I guess I'm not really sure what is meant specifically by confidence and which would be the right path (ha)

  9. jrmuizel commented on Aug 22, 2016

    @jrmuizel

    For this to be a valuable experiment for the gecko-webrender integration it's important for the implementation to be as webrendery as possible.

    A basic sketch of what this would like is as follows:

    • Add add_geometry, remove_geometry functions similar to the current add_image, remove_image functions
    • Add svg_geometry, svg_text, svg_effects display items
    • Geometry would be rasterized cpu side (but in parallel) just as glyphs are today.
    • Webrender would composite the svg display items similar to how it composites other display items today
  10. glennw commented on Aug 22, 2016

    @glennw
    Member

    That seems like a reasonable way forward. @jrmuizel I think when we last discussed this you suggested that we could use something "off the shelf" for the geometry rasterization part?

  11. metajack commented on Aug 22, 2016

    @metajack
    Collaborator

    @jrmuizel I like that plan.

  12. jrmuizel commented on Aug 22, 2016

    @jrmuizel

    For now, it's probably best just to use Skia or Cairo for the geometry rasterization part. Both of these have fairly fast software rasterizers and support stroking and dashing

    In the future we could experiment with something more sophisticated like Direct2D's rasterize to geometry approach or something else. However, that work is relatively well contained and as long as the majority of webcontent isn't going through this path I don't expect it to be a bottleneck that we need to care about in the near term.

  13. nical commented on Aug 23, 2016

    @nical
    Contributor

    Since I am mentioned here, the SVG work I have been doing is in the lyon repository. For now it mostly does one thing: provide tools to build and tessellate flattened path fill operations. It only generates triangles, and the renderer using it is responsible for uploading/displaying the geometry. I am very happy with the how the tessellator is working out, although since I am doing this entirely in my spare time, it is progressing very slowly (If anyone is interested in helping out it would be great).

    There's also a (work in progress) toy stroke tessellator that is simple but does not handle transparent overlapping geometry (overlapping pixels will be drawn twice instead of once).

    The repo is split into small crates, some of which may be useful even when not using the tessellators:

    • the lyon_bezier crate implements some useful quadratic and cubic bezier math including the flattening algorithm ported over from Gecko,
    • lyon_path_builder and lyon_path_iterator implement some neat tools to, well... build and iterate over path objects.

    Edit: I should mention that the tessellator only implements the even-odd fill rule at the moment, and that vertex-aa is not yet implemented (a bring your own anti-aliasing party for now). I'll eventually add whatever svg feature is missing when I have time.

  14. Ms2ger commented on Aug 23, 2016

    @Ms2ger
    Contributor
  15. gsnedders commented on Sep 30, 2016

    @gsnedders
    Contributor

    SVG 2 is now at CR, so is in principle now done. It makes a fair bit of stuff in SVG 1.1 optional, which also seems useful for this use-case. :)

  16. tigt commented on Jan 25, 2017

    @tigt

    Just a note that the SVG2 working group didn't have its charter renewed, and its future may be in doubt. (Those minutes also link to a spreadsheet where browsers declared intent on SVG2's proposed features.) As far as removing features, though, probably good enough.

    The WHATWG HTML5 spec has notes on conforming SVG features, but those were me researching what current browsers supported/didn't support. I'd be the first to say they should be challenged by any further knowledge.

  17. added
    B-feature-tracking
    on Jan 18, 2018
  18. pshaughn commented on Nov 28, 2019

    @pshaughn
    Contributor

    A lot of WPT tests want to see the SVG script element working.

  19. arihant2math commented on Oct 23, 2025

    @arihant2math
    Contributor

    Technically completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-feature-trackingB-meta

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions