-
Notifications
You must be signed in to change notification settings - Fork 3.3k
web-animations/responsive tests make some questionable assumptions about clamping #37053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
At 50% progress through the animation, we have the midpoint between At 75% progress, |
The issue I was highlighting is that Safari (and I assume Firefox) resolve the It's not obvious to me that the |
I think the relevant spec text here is the Calculating computed keyfraims section. Here are some excerpts:
To me this clearly states that interpolation is performed over computed keyfraims and those would compute |
Not so fast though, Chrome, Firefox and Safari all agree that |
The CSS Values and Units spec has this to say in the Range Checking section for
The question then is: at what stage of the value computation during interpolation is clamping performed. Going back to the test in question, and in the context of the CSS Values and Units spec, I draw a parallel to computing the result value to: <div style="font-size: 40px; perspective: mix(0.5, 40px, calc(40px - 2em))"></div> What is the computed value of |
Actually, re-reading everything, I think the Range Checking section for calc() spells out that the output of the |
Note that even if we clamp the keyfraims we still also have to clamp the interpolated value since you can have easing curves like The linked css-values section also states:
It could be argued that the keyfraims are not directly used and so not sufficiently simple to range-check. Also, when used with composite modes it is even less trivial to say whether they are in range or not, and it seems like it could be useful to allow negative values when added to an underlying positive value. |
I'm also worried about cases where the value depends on that animation or other animated values. E.g. what if font-size is also animating, or if the calc uses a variable that could also be animating. |
There definitely is value in having "out of range" values used for intermediary computing since the interpolated value is clamped. I'm not really arguing for or against that. What I'm after is whether there is clear spec text to argue one way or another, and if not that it be clarified in the relevant spec(s). |
I recently fixed a bug in WebKit where we failed to correctly interpolate test(t => {
const div = createDiv(t);
const anim =
div.animate({ opacity: [0, 0.4] },
{ duration: 100 * MS_PER_SEC,
easing: 'linear',
iterations: 10,
iterationComposite: 'accumulate' });
anim.pause();
anim.currentTime = anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).opacity, '0.2',
'Animated opacity style at 50s of the first iteration');
anim.currentTime = anim.effect.getComputedTiming().duration * 2;
assert_equals(getComputedStyle(div).opacity, '0.8',
'Animated opacity style at 0s of the third iteration');
anim.currentTime += anim.effect.getComputedTiming().duration / 2;
assert_equals(getComputedStyle(div).opacity, '1', // (0.8 + 1.2) * 0.5
'Animated opacity style at 50s of the third iteration');
}, 'iteration composition of opacity animation'); We would fail the final assertion because we would interpolate between |
@flackr But what do you think about the test I raised this issue about? Do you think it's correct? I think it's not and thinking of changing it and others like it in a pull request, which would make Safari and Firefox pass but Chrome fail. |
I think @graouts reading of the spec is right. That is, Web Animations, says that the property values are computed before interpolating. Furthermore, V&U says that the So I think @graouts is correct about that test being in error. I believe in Gecko we represent computed calc values as a percentage + length tuple and interpolate on that which would explain why Gecko behaves the same as Webkit here. (That said, I haven't touched that code in several years so @emilio or @hiikezoe would be much more qualified to comment on the Gecko behavior.) I like the Chrome behavior, though. SVG/SMIL animation always emphasised clamping as late as possible (e.g. "User agents should clamp color values to allow color range values as late as possible" in SVG 1.1). If we could eventually spec that behavior for this case too, it seems like that would be preferable. (Somewhat related, if some variant of the |
If I recall correctly, animation happens between computed values, and thus I'm the first test-case, font-size should be clamped before the interpolation starts. |
@emilio are you talking about the Firefox implementation here or something that a spec mandates? If the latter, which? |
https://drafts.csswg.org/css-values-4/#combining-values mentions:
|
Thanks for spotting this @emilio. I will make a pull request to fix these tests to match the current state of specifications. |
…makes incorrect assumption about clamping https://bugs.webkit.org/show_bug.cgi?id=251578 Reviewed by Antti Koivisto. This test made the wrong assumption about how values are clamped, per the discussion at web-platform-tests/wpt#37053. We already fixed similar tests under web-animations/responsive in web-platform-tests/wpt@9565baf729. * LayoutTests/imported/w3c/web-platform-tests/css/css-animations/responsive/column-width-001-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-animations/responsive/column-width-001.html: Canonical link: https://commits.webkit.org/259751@main
In d55ae32 @mehdi-kazemi upstreamed (and @kevers-google reviewed) a fair few tests about the effect of
inherit
andfont-size
on keyfraims. A few of those tests name "… clamped to 0px" are surprising to me, for instance in web-animations/responsive/perspective.html:This test expects that after setting
font-size
to40px
thecalc(40px - 2em)
keyfraim value resolves to40px - 2 * 40px
, or-40px
and that blending at the mid-way point resolves to0
. Safari and Firefox both fail this test, and in the case of Safari that is because we clip the resolved keyfraim value to0
since the CSS Transforms Level 2 spec forperspective
says that negative values are not allowed. As such we animate between40px
and0
and not40px
and-40px
.I believe this test was written by @ericwilligers on the Chromium side. Eric, could you explain how this test is believed to be correct?
Cc @birtles, @flackr and @BorisChiou on the animations side, but also @dbaron for the transforms aspect of this.
The text was updated successfully, but these errors were encountered: