Bug 23775 - Transitions misbehave when a property is expressed in different units
Summary: Transitions misbehave when a property is expressed in different units
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, HasReduction, InRadar
: 54647 63309 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-05 16:39 PST by Benoit Marchant
Modified: 2023-10-13 07:59 PDT (History)
14 users (show)

See Also:


Attachments
Test case for the bug (884 bytes, text/html)
2009-02-05 16:40 PST, Benoit Marchant
no flags Details
Improved testcase (774 bytes, text/html)
2022-09-14 05:30 PDT, Antoine Quint
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benoit Marchant 2009-02-05 16:39:09 PST
In the attached test case, the width doesn't animate because it's expressed as % at the beginning and as em when the transition should apply
Comment 1 Benoit Marchant 2009-02-05 16:40:18 PST
Created attachment 27370 [details]
Test case for the bug
Comment 2 Deirdre Saoirse Moen 2009-02-05 17:39:59 PST
rdar://problem/6561547
Comment 3 Simon Fraser (smfr) 2011-06-06 21:09:49 PDT
*** Bug 54647 has been marked as a duplicate of this bug. ***
Comment 4 Mike Lawther 2011-11-22 19:25:19 PST
*** Bug 63309 has been marked as a duplicate of this bug. ***
Comment 5 Ahmad Saleem 2022-09-01 16:34:48 PDT
I am not able to reproduce issue in reference to animation but the animation ends abruptly if mouse leaves container and come back in Safari Technology Preview 152 and it is not same as other browsers, where the animation ends back smoothly.

Do you want me to create separate bug for that and close this? Appreciate if someone can comment. Thanks!
Comment 6 Alexey Proskuryakov 2022-09-02 17:46:41 PDT
Good catch. This problem with interrupted transition only reproduces when the units are different, so I would say that it's a part of the original bug, and can continue to be tracked here.

Re-titled a bit to that effect.
Comment 7 Antoine Quint 2022-09-14 05:30:27 PDT
Created attachment 462331 [details]
Improved testcase

In the attached improved testcase, we automatically trigger, reverse the transition and log the values provided by the Web Animations API which are all out of whack in WebKit.
Comment 8 Antoine Quint 2022-09-14 05:35:28 PDT
Firefox / Chrome (actual values may vary):

Transitioning width from 10% to 960px
Transitioning width from calc(6.63989% + 322.571px) to 10%

Safari:

Transitioning width from 151.1875px to 151.1875px
Transitioning width from 151.1875px to 151.1875px

What puzzles me is that the from/to values are the same for the initial transition even though we do the right thing in terms of rendering. The second one is consistent with the fact that we snap, although it makes no sense to transition between two equal values.
Comment 9 Antoine Quint 2022-09-14 05:40:59 PDT
We are getting 10% and 960px values in the RenderStyle objects provided when creating the CSSTransition object.
Comment 10 Antoine Quint 2022-09-14 06:33:43 PDT
Huh-ho, so for the getKeyframes() issue the problem is that we are calling this method to get the computed value from the style in the addPropertyToKeyframe lambda:

computedStyleExtractor.valueForPropertyInStyle(style, cssPropertyId, renderer)

But this absolutely does not use the provided style object to get the width instead using the current bounds for the renderer. Not good!
Comment 11 Antoine Quint 2022-09-14 07:51:10 PDT
Filed bug 245179 for the getKeyframes() issue which is unrelated to the fact that we're not visibly animating for transition reversal.
Comment 12 Antoine Quint 2022-09-19 09:03:54 PDT
The issue is under static Length blendMixedTypes(const Length& from, const Length& to, const BlendingContext& context) where we have from = calc(blend(10%, 960px, 0.33)) and to = 10% but the result is calc(blend(10%, 10%, …)).
Comment 13 Antoine Quint 2022-09-19 09:05:24 PDT
I think this might be the culprit:

CalcExpressionBlendLength::CalcExpressionBlendLength(Length from, Length to, float progress)
    : CalcExpressionNode(CalcExpressionNodeType::BlendLength)
    , m_from(from)
    , m_to(to)
    , m_progress(progress)
{
    // Flatten nesting of CalcExpressionBlendLength as a speculative fix for rdar://problem/30533005.
    // CalcExpressionBlendLength is only used as a result of animation and they don't nest in normal cases.
    if (m_from.isCalculated() && m_from.calculationValue().expression().type() == CalcExpressionNodeType::BlendLength)
        m_from = downcast<CalcExpressionBlendLength>(m_from.calculationValue().expression()).from();
    if (m_to.isCalculated() && m_to.calculationValue().expression().type() == CalcExpressionNodeType::BlendLength)
        m_to = downcast<CalcExpressionBlendLength>(m_to.calculationValue().expression()).to();
}
Comment 14 Antoine Quint 2022-09-19 09:07:42 PDT
Indeed, removing that code fixes the issue. But this fixed a crash so we probably need to find a better way to flatten blend calculation values here.