Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Brian Birtles
Dear www-svg,

I would like to propose a change to the behaviour specified for
discrete to-animation in SVG 1.1 Second Edition.

Problem:
--------

According to SMIL Animation which is a normative reference for SVG 1.1
Second Edition:

  For the shorthand form to animation, there is only 1 value; a
discrete to animation will simply set the "to" value for the simple
duration.[1]

That means that the following two fragments will behave markedly differently:

  <rect width="100" height="50">
    <animate attributeName="width"
             calcMode="discrete"
             begin="0s" dur="2s"
             from="100"
             to="300"
             fill="freeze"/>
  </rect>

and:

  <rect width="100" height="50">
    <animate attributeName="width"
             calcMode="discrete"
             begin="0s" dur="2s"
             to="300"
             fill="freeze"/>
  </rect>

(Online test case here:
https://bug544855.bugzilla.mozilla.org/attachment.cgi?id=493392
although note that the order of animation is reversed.)

The first, a discrete from-to animation will set the width to 100 for
1s, and 300 for 1s (and onwards due to fill behaviour).

The second, a discrete to animation will set the width to 300s from the start.

This seems very confusing for authors who are not also SMIL model experts.

This issue was raised a year ago by Julien Reichel who pointed out
that animate-elem-227-t.svg mandates the wrong behaviour[2] and also
by Dr. Olaf Hoffman and Julien on several occasions prior.[3]

Proposed change:
----------------

In section 19.2.9 'Attributes that define animation values over time'
change the paragraph:

  The processing rules for the variants of from/by/to animations are described
  in Animation function values.

to:

  The processing rules for the variants of from/by/to animations are
  described in Animation function values with the following exception.

  In order to provide intuitive and consistent behavior when the starting
  value of an animation is explicitly specified by a "from" attribute (e.g.
  "from-to animation") and when the underlying value is used (e.g. "to
  animation") the behavior of discrete to-animation in SVG deviates from the
  definition in SMIL Animation.

  As with a discrete from-to animatiom, a discrete to animation will set the
  underlying value for the first half of the simple duration (or, if a
  keyTimes list is provided, until the offset into the simple duration
  specified by the second value in the keyTimes list) and the "to" value for
  the remainder of the simple duration.

I've tried to follow the wording of SMIL Animation 3.2.3[1] although I
note that the wording of SMIL Animation at this point seems to neglect
the possibility of keyTimes being specified (unless "half" is not
meant literally).

(For the record, from/to/by syntax can be used in conjunction with keyTimes.[4])

If we want to use formulae like SMIL 3 uses we could have:

  When no keyTimes attribute is specified, d_1 is the mid-point of the simple
  duration, d/2. Otherwise d_1 = keyTimes[1].

  The simple animation function for discrete to-animation is then:
    f(t,u) = u, for t: 0 <= t < d_1
    f(t,u) = v_t, for t: d_1 <= t <= d

Interoperability:
-----------------

Opera 11.01, Batik 1.7, and WebKit nightly build r80213 (3 Mar 2011)
all provide identical animation for both of the provided examples.
i.e. they do not conform to the specified behaviour but follow this
proposal.

(I note however that Opera and WebKit appear to ignore keyTimes in this case.)

Apparently ASV also does not follow the specified behaviour.[5]

Firefox 4 will ship with the behaviour specified by SMIL Animation. If
this proposal is accepted however we will revert the behaviour before
the next major release.

I raised this issue at last week's F2F and most people seemed to
agree. I assumed it was too late to fix this in SVG 1.1 Second Edition
but perhaps that is not the case after all.

Rationale:
----------

* The proposed change makes the behaviour of discrete from-to/to
animation analogous to linear from-to/to animation and hence more
intuitive.
* The rationale for the currently specified behaviour is unclear.[6]
* The fact that test animate-elem-227-t.svg mandates the wrong
behaviour is evidence that this is confusing.
* The specified behaviour is largely unimplemented and hence changing
it should not break large amounts of existing content.
* The behaviour of setting the to-value for the entire duration can be
achieved with <set>.

This issue has come up many times before, let's fix it now. Any
objections or corrections to my proposal are very welcome.

I hope, in the coming days to provide a similar write-up for a couple
of the other minor issues raised at last week's F2F.[7]

Regards,

Brian Birtles

[1] http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
[2] http://lists.w3.org/Archives/Public/www-svg/2010Feb/0015.html
[3] http://lists.w3.org/Archives/Public/www-smil/2008JanMar/0040.html
and following thread:
    http://lists.w3.org/Archives/Public/www-smil/2008JulSep/0001.html, and
    http://lists.w3.org/Archives/Public/www-svg/2008Sep/0027.html
[4] http://www.w3.org/TR/SMIL/smil-animation.html#animationNS-InterpolationKeysplines
[5] http://lists.w3.org/Archives/Public/www-svg/2008Sep/0026.html
[6] http://lists.w3.org/Archives/Public/www-smil/2008JulSep/0011.html
[7] http://www.w3.org/Graphics/SVG/WG/wiki/F2F/Auckland_2011/Animation_improvements

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Brian Birtles
Dear Olaf,

Thank you very much for your mail. I appreciate your feedback very
much. I'd like to respond to your comments one by one.

> well, with the behaviour defined in SMIL the discrete to-animation
> is comparable to a set-animation. Is it confusing too, that set sets
> the value at the begin of the active duration and not in the middle?
> And it is comparable with a values-animation, if values contains
> only one list item. Is it confusing too, that this type of animation
> sets the value at the begin of the active duration and not in the
> middle?

Regarding comparison with set-animation and values-animation I think a
much more natural comparison is with from-to animation and with
to-animation of another calcMode.

For example, with an underlying value of 100,

from=200 to=300 calcMode=linear   --> animation from 200 to 300
from=200 to=300 calcMode=discrete --> animation from 200 to 300
         to=300 calcMode=linear   --> animation from 100 to 300
         to=300 calcMode=discrete --> animation sets value to 300

Clearly the last line seems inconsistent. By comparison to the other
animations one would expect the result to be animation from 100 to
300.

Considering just the last two lines, I believe it is intuitive to
expect the calcMode=discrete animation to simply be a stepped version
of the linear case. In fact, if the target attribute is not
interpolatable the user agent will automatically fall back to
calcMode=discrete in which case I believe a comparable animation
should result.[1]

Set animation and values animation are more distant syntactically and
conceptually.

> I think, because it is defined in all SMIL versions in the same way,
> there should be no inconsistent change in  SVG 1.1 Second Edition,
> resulting mainly in even more complications.

I originally thought the same way[2] but I've since come to think that
this behaviour is so counter-intuitive as to warrant changing the
spec.

The evidence for this is:
* Every implementation I've encountered (besides the one I "fixed")
does not comform to this part of the spec. I take this as evidence
that what the spec defines does not naturally fall out of the model
but is inconsistent.
* The SVG 1.1 Test Suite does not conform to this part of the spec but
mandates what I have proposed and believe is more intuitive.
* Content authors have expressed surprise at this unexpected behaviour.[3]

Rather than trying to bend people's intuition to match an abitrary
spec, I think it is better to bend the spec to match intuition.

> It is nice, that to-animations are implemented better in
> Mozilla/Gecko than in most other viewers, this indicates, that
> a useful feature is implementable, and maybe one time, bugs
> in other viewers are fixed, it will really become usable for authors ;o)

I agree it is implementable, but I don't understand why it is useful.
As you rightly point out, the same behaviour is already possible with
set-animation and values-animation.

> Because set-animations are not applicable for the transform attribute,
> discrete to-animations could be really useful. For most other attributes
> however, discrete to-animation are typically not very interesting, because
> single-item-values-animations or set-animations can be used.

Ultimately I hope we can remove animateTransform altogether (in which
case it should be possible to target a transform attribute with set)
but until then, it seems it is still possible to set a transform value
for the entire duration of an interval using a values-animation.

Thanks again,

Best regards,

Brian Birtles

[1] http://www.w3.org/TR/smil-animation/#AnimFuncCalcMode
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=544855#c4
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=544855#c11

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Cameron McCormack-4
In reply to this post by Brian Birtles
Hi Brian.

I have SVG-ACTION-3013 to look into this.  I believe the changes are
good, and I like your proposed wording but have comment on it:

Brian Birtles:

> Proposed change:
> ----------------
>
> In section 19.2.9 'Attributes that define animation values over time'
> change the paragraph:
>
>   The processing rules for the variants of from/by/to animations are described
>   in Animation function values.
>
> to:
>
>   The processing rules for the variants of from/by/to animations are
>   described in Animation function values with the following exception.
>
>   In order to provide intuitive and consistent behavior when the starting
>   value of an animation is explicitly specified by a "from" attribute (e.g.
>   "from-to animation") and when the underlying value is used (e.g. "to
>   animation") the behavior of discrete to-animation in SVG deviates from the
>   definition in SMIL Animation.

This paragraph confused me on first read.  I think it would be slightly
clearer like this:

  In order to provide behavior that is intuitive and consistent between
  discrete animations with an explicitly specified "from" attribute
  (e.g. "from-to animation") and those where the underlying value is
  used (e.g. "to animation"), the behavior of discrete to-animation in
  SVG deviates from the definition in SMIL Animation.

>   As with a discrete from-to animatiom, a discrete to animation will set the
>   underlying value for the first half of the simple duration (or, if a
>   keyTimes list is provided, until the offset into the simple duration
>   specified by the second value in the keyTimes list) and the "to" value for
>   the remainder of the simple duration.

> Interoperability:
> -----------------
>
> Opera 11.01, Batik 1.7, and WebKit nightly build r80213 (3 Mar 2011)
> all provide identical animation for both of the provided examples.
> i.e. they do not conform to the specified behaviour but follow this
> proposal.
>
> (I note however that Opera and WebKit appear to ignore keyTimes in this case.)

I made a simple test, too:

  http://dev.w3.org/SVG/profiles/1.1F2/test/svg/animate-elem-92-t.svg

I would prefer to make this change only if we test it (by approving the
above test) and if we have at least two passing implementations of it.
As you mention, Opera and WebKit ignore keyTimes on discrete to-
animations, so of the above implementations (which are the only ones I
currently have access to that implement animation) only Batik passes the
test.

--
Cameron McCormack ≝ http://mcc.id.au/

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Erik Dahlström
On Mon, 28 Mar 2011 00:18:04 +0200, Cameron McCormack <[hidden email]>  
wrote:

> Hi Brian.
>
> I have SVG-ACTION-3013 to look into this.  I believe the changes are
> good, and I like your proposed wording but have comment on it:
>
> Brian Birtles:
>> Proposed change:
>> ----------------
...
>>   As with a discrete from-to animatiom, a discrete to animation will  
>> set the
>>   underlying value for the first half of the simple duration (or, if a
>>   keyTimes list is provided, until the offset into the simple duration
>>   specified by the second value in the keyTimes list) and the "to"  
>> value for
>>   the remainder of the simple duration.

Either leave the 'keyTimes' part out, or you have to clarify the  
'keyTimes' attribute too (it's currently implying that there has to be a  
'values' attribute for it to have an effect).

>> Interoperability:
>> -----------------
>>
>> Opera 11.01, Batik 1.7, and WebKit nightly build r80213 (3 Mar 2011)
>> all provide identical animation for both of the provided examples.
>> i.e. they do not conform to the specified behaviour but follow this
>> proposal.
>>
>> (I note however that Opera and WebKit appear to ignore keyTimes in this  
>> case.)

I think this is because both the SMIL and SVG specs say that 'keyTimes'  
corresponds to the 'values' attribute, and that it should have no effect  
on to/by/from-by/from-to animations, e.g:

[[ 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. ]]

and

[[ If a list of ‘keyTimes’ is specified, there must be exactly as many  
values in the ‘keyTimes’ list as in the ‘values’ list. ]]


Cheers
/Erik

--
Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Brian Birtles
In reply to this post by Cameron McCormack-4
Hi Cameron,

Thanks for looking into this.

On 28 March 2011 07:18, Cameron McCormack <[hidden email]> wrote:

>>   In order to provide intuitive and consistent behavior when the starting
>>   value of an animation is explicitly specified by a "from" attribute (e.g.
>>   "from-to animation") and when the underlying value is used (e.g. "to
>>   animation") the behavior of discrete to-animation in SVG deviates from the
>>   definition in SMIL Animation.
>
> This paragraph confused me on first read.  I think it would be slightly
> clearer like this:
>
>  In order to provide behavior that is intuitive and consistent between
>  discrete animations with an explicitly specified "from" attribute
>  (e.g. "from-to animation") and those where the underlying value is
>  used (e.g. "to animation"), the behavior of discrete to-animation in
>  SVG deviates from the definition in SMIL Animation.

Sounds great.

> I made a simple test, too:
>
>  http://dev.w3.org/SVG/profiles/1.1F2/test/svg/animate-elem-92-t.svg
>
> I would prefer to make this change only if we test it (by approving the
> above test) and if we have at least two passing implementations of it.
> As you mention, Opera and WebKit ignore keyTimes on discrete to-
> animations, so of the above implementations (which are the only ones I
> currently have access to that implement animation) only Batik passes the
> test.

Oh, that's a shame. Fixing Gecko should hopefully be as simple as
backing out the patch where we "fixed" this (bug 544855). I'm happy to
do that if you're confident we can get this changed in the spec.
Otherwise, I wonder what Abbra does?

Of course, that depends on resolving the issue about whether keyTimes
should affect to animations that Erik raised. I believe SMIL
explicitly says that it does:

  The keyTimes and keySplines attributes may also be used with the
from/to/by shorthand forms for specifying values[1]

Best regards,

Brian

[1] http://www.w3.org/TR/SMIL/smil-animation.html#animationNS-InterpolationKeysplines

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Alex Danilo
Hi Brian,

--Original Message--:

>Hi Cameron,
>
><snip/>
>> I made a simple test, too:
>>
>>  http://dev.w3.org/SVG/profiles/1.1F2/test/svg/animate-elem-92-t.svg
>>
>> I would prefer to make this change only if we test it (by approving the
>> above test) and if we have at least two passing implementations of it.
>> As you mention, Opera and WebKit ignore keyTimes on discrete to-
>> animations, so of the above implementations (which are the only ones I
>> currently have access to that implement animation) only Batik passes the
>> test.
>
>Oh, that's a shame. Fixing Gecko should hopefully be as simple as
>backing out the patch where we "fixed" this (bug 544855). I'm happy to
>do that if you're confident we can get this changed in the spec.
>Otherwise, I wonder what Abbra does?

I've been ignoring this thread due to other distractions.

If I get a chance over the next day or so I'll try to get this
checked out for you.

Cheers,
Alex

>Best regards,
>
>Brian
>
>[1] http://www.w3.org/TR/SMIL/smil-animation.html#animationNS-InterpolationKeysplines
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Cameron McCormack-4
In reply to this post by Brian Birtles
Hi Brian.

Cameron McCormack:
> > I would prefer to make this change only if we test it (by approving the
> > above test) and if we have at least two passing implementations of it.
> > As you mention, Opera and WebKit ignore keyTimes on discrete to-
> > animations, so of the above implementations (which are the only ones I
> > currently have access to that implement animation) only Batik passes the
> > test.

Brian Birtles:
> Oh, that's a shame. Fixing Gecko should hopefully be as simple as
> backing out the patch where we "fixed" this (bug 544855). I'm happy to
> do that if you're confident we can get this changed in the spec.
> Otherwise, I wonder what Abbra does?

Yes, barring any pushback in the WG (which hasn’t been seen so far –
it’d be good to see what Alex’s opinion is), if this goes out in a
nightly Firefox build then that will be sufficient for the
implementation report, and we can make this change for Second Edition.

> Of course, that depends on resolving the issue about whether keyTimes
> should affect to animations that Erik raised. I believe SMIL
> explicitly says that it does:
>
>   The keyTimes and keySplines attributes may also be used with the
> from/to/by shorthand forms for specifying values[1]

I agree, but we will discuss this in the WG.

--
Cameron McCormack ≝ http://mcc.id.au/

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Alex Danilo
In reply to this post by Brian Birtles
Hi Brian,

--Original Message--:

><snip/>
>> I made a simple test, too:
>>
>>  http://dev.w3.org/SVG/profiles/1.1F2/test/svg/animate-elem-92-t.svg
>>
>> I would prefer to make this change only if we test it (by approving the
>> above test) and if we have at least two passing implementations of it.
>> As you mention, Opera and WebKit ignore keyTimes on discrete to-
>> animations, so of the above implementations (which are the only ones I
>> currently have access to that implement animation) only Batik passes the
>> test.
>
>Oh, that's a shame. Fixing Gecko should hopefully be as simple as
>backing out the patch where we "fixed" this (bug 544855). I'm happy to
>do that if you're confident we can get this changed in the spec.
>Otherwise, I wonder what Abbra does?

I just checked this out.

We do what Opera and WebKit do, namely switch at the 2 second
point (mid-point) of the discrete to animation. Also, we ignore
the keyTimes so the change happens at 4s instead of 2s for Cameron's
last test case in 92-t.

This is just another data point for you, I don't claim it's
what SMIL expects...

Cheers,
Alex

>Of course, that depends on resolving the issue about whether keyTimes
>should affect to animations that Erik raised. I believe SMIL
>explicitly says that it does:
>
>  The keyTimes and keySplines attributes may also be used with the
>from/to/by shorthand forms for specifying values[1]
>
>Best regards,
>
>Brian
>
>[1] http://www.w3.org/TR/SMIL/smil-animation.html#animationNS-InterpolationKeysplines
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Brian Birtles
Hi Alex,

On 7 April 2011 10:37, Alex Danilo <[hidden email]> wrote:
> I just checked this out.
>
> We do what Opera and WebKit do, namely switch at the 2 second
> point (mid-point) of the discrete to animation. Also, we ignore
> the keyTimes so the change happens at 4s instead of 2s for Cameron's
> last test case in 92-t.
>
> This is just another data point for you, I don't claim it's
> what SMIL expects...

That's good to know. It gives us confidence that the proposed change
will bring the specification into line with implementations (and
common sense, since I believe the implementations are doing what is
most intuitive in this case).

I think the keyTimes issue is a bug (and that Cameron's test is
correct) since I believe SMIL does say that keyTimes apply to
to-animation as well[1] but I'm not fussed whether the proposed
keyTimes wording ends up in the spec or not.

Thanks again Alex,

Brian

[1] http://www.w3.org/TR/SMIL/smil-animation.html#animationNS-InterpolationKeysplines

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Alex Danilo
Hi Brian,

--Original Message--:

>Hi Alex,
>
>On 7 April 2011 10:37, Alex Danilo <[hidden email]> wrote:
>> I just checked this out.
>>
>> We do what Opera and WebKit do, namely switch at the 2 second
>> point (mid-point) of the discrete to animation. Also, we ignore
>> the keyTimes so the change happens at 4s instead of 2s for Cameron's
>> last test case in 92-t.
>>
>> This is just another data point for you, I don't claim it's
>> what SMIL expects...
>
>That's good to know. It gives us confidence that the proposed change
>will bring the specification into line with implementations (and
>common sense, since I believe the implementations are doing what is
>most intuitive in this case).
>
>I think the keyTimes issue is a bug (and that Cameron's test is
>correct) since I believe SMIL does say that keyTimes apply to
>to-animation as well[1] but I'm not fussed whether the proposed
>keyTimes wording ends up in the spec or not.

Looking at our code, we don't even consider keyTimes unless there's
a values list. That was written years ago, before SMIL 3 existed
so makes sense. If the test gets approved, I guess that'll need to
be fixed...

Interestingly, the SMIL 3 spec. you quoted says this:
"The keyTimes and keySplines attributes may also be used with the
from/to/by shorthand forms for specifying values"

which seems to imply 'to' animations are just shorthand for
list of values rather than a completely different type of
animation. I don't recall if that's changed from 2 since
it's a long time since I've looked at it.

>Thanks again Alex,

You're welcome,
Alex

>Brian
>
>[1] http://www.w3.org/TR/SMIL/smil-animation.html#animationNS-InterpolationKeysplines
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Cameron McCormack-4
In reply to this post by Brian Birtles
Hi Brian.

Brian Birtles:
> Oh, that's a shame. Fixing Gecko should hopefully be as simple as
> backing out the patch where we "fixed" this (bug 544855). I'm happy to
> do that if you're confident we can get this changed in the spec.

I’ve changed Gecko and the spec:

  https://bugzilla.mozilla.org/show_bug.cgi?id=651036
  http://dev.w3.org/SVG/profiles/1.1F2/publish/animate.html#ValueAttributes

--
Cameron McCormack ≝ http://mcc.id.au/

Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Fix discrete to animation in SVG 1.1 Second Edition

Brian Birtles
Hi Cameron,

On 21 April 2011 09:04, Cameron McCormack <[hidden email]> wrote:
> I’ve changed Gecko and the spec:
>
>  https://bugzilla.mozilla.org/show_bug.cgi?id=651036
>  http://dev.w3.org/SVG/profiles/1.1F2/publish/animate.html#ValueAttributes

Thanks so much mate. Sorry I've been out of action. Suddenly got a
chance to go and help with the volunteer work here and so was offline
for a couple of weeks.

Thanks again,

Brian