Correctly compute keyframe at timestamp 0; Early return when possible#354
Conversation
|
@Loirooriol Just friendly reminder. |
|
|
||
| let prev_keyframe = &self.computed_steps[prev_keyframe_index]; | ||
| let Some(next_keyframe_index) = next_keyframe_index else { | ||
| debug_assert!(false, "next_keyframe_index should always be Some"); |
There was a problem hiding this comment.
Using debug_unreachable may be clearer.
Also the message isn't providing much, it should rather explain why.
There was a problem hiding this comment.
Done in 2701332
The explanation is a bit lengthy tho. We are relying on
stylo/style/servo/animation.rs
Lines 175 to 176 in 40aa59d
| // Progress clamped to the current iteration (0.0 to 1.0). | ||
| let total_progress = progress.min(self.current_iteration_end_progress()).max(0.0); | ||
|
|
||
| if total_progress >= 1.0 { |
There was a problem hiding this comment.
Why can this handle the equality, but above you check progress < 0.0?
There was a problem hiding this comment.
In 2701332 I updated to ==1.0 as it is always in [0,1].
but above you check
progress < 0.0?
At progress == 0.0, we don't want to early return because we need to reach the step‑function handling block at L878 we added.
There was a problem hiding this comment.
But don't we have the same jumping problem at the end?
There was a problem hiding this comment.
End has always been fine. We only have problem at the beginning.
398c241 to
1d1f9ce
Compare
dbc9ddd to
0cf455c
Compare
0cf455c to
ff53dff
Compare
|
@Loirooriol Do you still have other concerns for this? |
xiaochengh
left a comment
There was a problem hiding this comment.
My previous comments at #342 seem unaddressed:
|
I have removed special casing for step functions in 4c6b772. It is no longer imported. This should be much more straightforward to review now. We do miss one early return, but the readability is worth it. Now the PR is mostly renaming, reordering, adding comments, and computing index at boundary correctly. |
|
@Loirooriol Xiaocheng would probably be off this week. Do you mind checking this again? |
…rst keyframe to be selected at progress 0; changed to < for normal direction (kept <= for reverse to avoid #342 (comment)) and added direction‑aware step‑function handling. - Guard against division‑by‑zero for zero‑length keyframe intervals. 1. total_progress ≥ 1.0 and total_progress < 0 now handled immediately. Also make it direction aware. 2. At timestamp 0, for normal direction, non‑jump step functions (jump‑end, jump‑none, end) now return the start‑keyframe value early, instead of proceeding to interpolation. 3. Zero-interval: we exit early to avoid division‑by‑zero in `percentage_between_keyframes` Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
4c6b772 to
fdd0908
Compare
xiaochengh
left a comment
There was a problem hiding this comment.
The implementation change looks very reasonable to me.
|
@Loirooriol @mrobinson I don't mean to nag. This isn't rocket science, but has been pended for two months. I also asked @Loirooriol two weeks ago if you still have concerns but just getting ignored. |
|
Nit: maybe we need to modify the PR title, since the special handling for step functions have been removed? |
jump-both, jump-start, start at timestamp 0; Early return when possible
mrobinson
left a comment
There was a problem hiding this comment.
Looks good with the nits below:
| let keyframe = match self.current_direction { | ||
| AnimationDirection::Normal => self.computed_steps.first().unwrap(), | ||
| AnimationDirection::Reverse => self.computed_steps.last().unwrap(), | ||
| _ => unreachable!(), | ||
| }; | ||
| add_declarations_to_map(keyframe); |
There was a problem hiding this comment.
Let's avoid unwrap() here and also below:
| let keyframe = match self.current_direction { | |
| AnimationDirection::Normal => self.computed_steps.first().unwrap(), | |
| AnimationDirection::Reverse => self.computed_steps.last().unwrap(), | |
| _ => unreachable!(), | |
| }; | |
| add_declarations_to_map(keyframe); | |
| if let Some(keyframe) = match self.current_direction { | |
| AnimationDirection::Normal => self.computed_steps.first(), | |
| AnimationDirection::Reverse => self.computed_steps.last(), | |
| _ => unreachable!(), | |
| } { | |
| add_declarations_to_map(keyframe); | |
| } |
There was a problem hiding this comment.
stylo/style/servo/animation.rs
Lines 173 to 176 in a683655
But the animation is guaranteed to have them. We also unwrapped earlier in previous code.
There was a problem hiding this comment.
Still we should avoid unwrap when possible (servo/servo#40744). If the code above changes, the person changing it might not get to this code, which can cause a panic later on.
There was a problem hiding this comment.
Good point! I guess there's nothing we can do with unwrap in this debug_assert.
Done in 01ef6d6
|
@mrobinson Thanks for review! Addressing this soon. |
There was a problem hiding this comment.
I have replaced the unreachable string as "Current animation direction can only be normal or reverse" instead, to be consistent with
stylo/style/servo/animation.rs
Lines 557 to 558 in a683655
fn iterate.
| let keyframe = match self.current_direction { | ||
| AnimationDirection::Normal => self.computed_steps.first().unwrap(), | ||
| AnimationDirection::Reverse => self.computed_steps.last().unwrap(), | ||
| _ => unreachable!(), | ||
| }; | ||
| add_declarations_to_map(keyframe); |
There was a problem hiding this comment.
stylo/style/servo/animation.rs
Lines 173 to 176 in a683655
But the animation is guaranteed to have them. We also unwrapped earlier in previous code.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
…ame correctly; Eliminate Stylo static preference hashing (servo#44365) Stylo PR: servo/stylo#354 This also includes servo/stylo#367 which eliminates static pref hashing Testing: New passes in existing tests: revert-rule, css-easing, css-logical. [revert-rule](https://drafts.csswg.org/css-cascade-5/#revert-rule-keyword) seems to be one of latest CSS keywords. I cannot even find it in MDN. Fixes: servo#43086 I'm unable to reopen the previous PR servo#43594. --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
jump-both,jump-start,startat timestamp 0; Early return when possible #342 (comment)) and added direction‑aware step‑function handling.Make early return happen earlier:
percentage_between_keyframesTry
Servo PR: servo/servo#44365