An annoying SVG animation bug in Chrome


Writing web standards is hard0. You have to write a formal specification which is useful for machines, humans, and web developers1.

I recently stumbled across what I think is a little bug which might be caused by a misreading of the SVG Animation specification. Here you should see two overlapping circles gradually appear:

If you're on Chrome, you might only see one circle animate. Why? Bloody semicolons! The bane of every programmer's existence2.

The specification for SVG Animation has this text for human readers:

keyTimes

A semicolon-separated list of time values used to control the pacing of the animation. Each time in the list corresponds to a value in the ‘values’ attribute list, and defines when the value is used in the animation function.

[…]

If the last semicolon separator is followed by either just white space or no more characters, ignore both the separator and the trailing white space.

To me, that isn't ambiguous. The text keyTimes="0; 1;" has a final semicolon with nothing after it. Therefore it should be ignored. Instead, Chrome throws an hissyfit and says Error: <animate> attribute keyTimes: Invalid value, "0; 1;".

But maybe the humans who wrote the description were sloppy. There's also a machine-readable formal specification. It defines the acceptable sequence as being:

<number> [; <number>]* ;?

This isn't quite Backus–Naur form3, but rather CSS Values.

  • The <number> is a component.
  • The [ and ] are grouping combinators.
  • The * and ? are component multipliers
    • * "indicates that the preceding type, word, or group occurs zero or more times."
    • ? "indicates that the preceding type, word, or group is optional (occurs zero or one times)."
  • The ; is just a semicolon 4 .

Reading the definition tells us that a valid value will be a number, followed by zero-or-more groups of "semicolon and another number" with an optional final semicolon.

So, based on my reading, I think Chrome is wrong to throw an error here. Both Firefox and Safari work with a trailing semicolon.

Accordingly, I've raised a bug with the Chromium team. If you think I have erred in this matter, please let me know.


  1. I do have some experience in this matter↩︎

  2. Back in 2006, Catharine A. MacKinnon provokatively asked "Are Women Human?". Her argument (which I shall badly summarise) is that if women were human, then they'd be protected by universal human rights. Given the state of the world then (and now) it is hard to argue that women receive as great a level of attention as the default male. I don't intend to trivialise MacKinnon's work - but I do find it interesting that developers are often treated separately from other humans. ↩︎

  3. I imagine English literature students also find them confusing; everyone does. ↩︎

  4. Also the bane of programmers everywhere! ↩︎

  5. Just like how sometimes a cigar is just a cigar↩︎


Share this post on…

One thought on “An annoying SVG animation bug in Chrome”

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

See allowed HTML elements: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">

To respond on your own website, write a post which contains a link to this post - then enter the URl of your page here.
Learn more about WebMentions.