Closed Bug 1877383 Opened 1 year ago Closed 11 months ago

[css-properties-values-api] Animated registered property in @keyframes without end state doesn't seem to interpolate properly

Categories

(Core :: CSS Parsing and Computation, defect, P3)

defect

Tracking

()

RESOLVED FIXED
125 Branch
Tracking Status
firefox125 --- fixed

People

(Reporter: nchevobbe, Assigned: zrhoffman)

References

(Blocks 3 open bugs, Regressed 1 open bug)

Details

Attachments

(2 files)

Steps to reproduce

  1. Navigate to data:text/html,<meta charset=utf8><style>@property --bg { syntax: "<color>"; initial-value: cyan; inherits: true;}%20 div { display: inline-block; margin: 20px;background-color: var(--bg);width: 50px;height: 50px; animation: color 2s infinite;} .a {%20 animation-name: colora; } .b { animation-name: colorb;} @keyframes colora { 0% { --bg: gold; } 100% { --bg: tomato; } } @keyframes colorb { 0%,50% { --bg: tomato; } } </style><div class=a>A</div><div class=b>B</div>

Expected results

Both A and B squares background color is animated

Actual results

B square background color is not animated, it jumps to cyan mid-animation


Here's the CSS in a more readable way:

@property --bg {
  syntax: "<color>";
  initial-value: cyan;
  inherits: true;
}
div {
  background-color: var(--bg);
  animation: color 2s infinite;
}
.a {
  animation-name: colora;
}
.b {
  animation-name: colorb;
}
@keyframes colora {
  0% {
    --bg: gold;
  }
  100% {
    --bg: tomato;
  }
}
@keyframes colorb {
  0%,
  50% {
    --bg: tomato;
  }
}

The issue seems to be in colorb keyframes, where we don't set an end state.
In Chrome and Safari, B square is properly animated

zsun, is this a known limitation? If so feel free to close this bug if there's another one to cover this case

Flags: needinfo?(zsun)

In the case of colorb, it looks like the color values for self and other are the same in Animate::CustomAnimatedValue <https://searchfox.org/mozilla-central/rev/2c3d657cbba5484ccac44443c4417baed7b5fafb/servo/components/style/properties_and_values/value.rs#544>, which causes self.value.animate to fail for most Procedure::Interpolate progresses.

Probably Servo_StyleSet_GetKeyframesForName <https://searchfox.org/mozilla-central/rev/2c3d657cbba5484ccac44443c4417baed7b5fafb/servo/ports/geckolib/glue.rs#6483> will need to be changed, since that's where the duplicate values are coming from, but I haven't pinpointed where yet.

Thanks Zach!

Flags: needinfo?(zsun)
Attached file Clearer test-case.

Both squares should probably animate equally.

The issue is not comment 2. The problem is that when we get an animated value from the computed style (such as when omitting the start or end keyframe) we lose the type information here.

We should carry over that type information somehow or look it up.

Severity: -- → S3
Priority: -- → P3

Sorry, I should have corrected myself when I realized that comment 2 was not correct.

Specifically, hasAdditiveValues <https://searchfox.org/mozilla-central/rev/6b8a3f804789fb865f42af54e9d2fef9dd3ec74d/dom/animation/KeyframeEffect.cpp#571> is returning false because aProperty.mToValue is initially null, resulting in trying to use a ComputedValue::Universal for the other value used for interpolation, since not yet having implemented bug 1864736 means that the computed style for registered custom properties is still untyped.

If the condition at <https://searchfox.org/mozilla-central/rev/6b8a3f804789fb865f42af54e9d2fef9dd3ec74d/dom/animation/KeyframeEffect.cpp#571> is instead changed to

      (hasAdditiveValues(aProperty) && !aProperty.mProperty.IsCustom());

since mToValue is computed later in the case of a custom property, value will interpolate successfully in CustomAnimatedValue::Animate <https://searchfox.org/mozilla-central/rev/2c3d657cbba5484ccac44443c4417baed7b5fafb/servo/components/style/properties_and_values/value.rs#548>, but child_restyle_requirement will still not be set to ChildRestyleRequirement::MustCascadeChildren at <https://searchfox.org/mozilla-central/rev/6b8a3f804789fb865f42af54e9d2fef9dd3ec74d/servo/components/style/traversal.rs#427> for colorb in the testcase like it does for colora (though I have not yet tested carrying over or looking up that type information, as suggested in comment 5).

So if the type information is not looked up or carried over, a condition determining whether compute_style returns ChildRestyleRequirement::MustCascadeChildren should probably be changed.

(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)

The issue is not comment 2. The problem is that when we get an animated value from the computed style (such as when omitting the start or end keyframe) we lose the type information here.

We should carry over that type information somehow or look it up.

You are right, carrying over the type animation does make the testcase behave as expected.

Depends on: 1881119
Depends on: 1864736
No longer depends on: 1881119

animation/custom-property-animation-transform-none.tentative.html now
fails for the first time since bug 1846516, and is tracked in bug
1861408.

Also add a TODO for bug 1883255, since this fixes bug 1870348.

Assignee: nobody → zach
Status: NEW → ASSIGNED
Blocks: 1884606
Pushed by zach@zrhoffman.net: https://hg.mozilla.org/integration/autoland/rev/230e45fd2ece Preserve computed registered custom property types. r=firefox-style-system-reviewers,emilio

Backed out for causing build bustages.

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: error[E0599]: no method named is_parsed found for reference &Value<GenericValueComponent<CSSPixelLength, f32, Percentage, ..., ..., ..., ..., ..., ..., ..., ..., ...>> in the current scope
Flags: needinfo?(zach)

Had to add #[cfg(debug_assertions)] to a debug_assert using a debug-only function.

Flags: needinfo?(zach)
Pushed by zach@zrhoffman.net: https://hg.mozilla.org/integration/autoland/rev/1f4f2a707dbc Preserve computed registered custom property types. r=firefox-style-system-reviewers,emilio
Status: ASSIGNED → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
Blocks: 1870348
Regressions: 1884971
Regressions: 1886780
See Also: → 1899531
See Also: 1899531
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: