Bug 109010 - SVG paced value animations overwrite user-provided keyTimes
Summary: SVG paced value animations overwrite user-provided keyTimes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 420+
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-02-05 23:38 PST by Philip Rogers
Modified: 2021-04-13 01:06 PDT (History)
10 users (show)

See Also:


Attachments
Repro (1.14 KB, text/html)
2013-02-05 23:38 PST, Philip Rogers
no flags Details
Patch (18.24 KB, patch)
2021-04-12 18:24 PDT, Said Abou-Hallawa
rniwa: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (18.20 KB, patch)
2021-04-12 20:12 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Rogers 2013-02-05 23:38:23 PST
Created attachment 186766 [details]
Repro

Paced animations can synthesize keytimes in SVGAnimationElement::calculateKeyTimesForCalcModePaced() but this overwrites user-provided values. If an animation's calcMode is later changed to be something other than 'paced', m_keyTimes will contain synthesized values instead of the user-provided values.
Comment 1 Said Abou-Hallawa 2021-04-12 18:24:03 PDT
Created attachment 425821 [details]
Patch
Comment 2 Ryosuke Niwa 2021-04-12 18:41:11 PDT
Comment on attachment 425821 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=425821&action=review

> Source/WebCore/svg/SVGAnimationElement.cpp:385
> -        if (m_keyTimes[index] > percent)
> +        if (keyTimes()[index] > percent)

Can we store a reference instead of keep calling this function?

> Source/WebCore/svg/SVGAnimationElement.cpp:414
> +    float fromPercent = keyTimes()[index];
> +    float toPercent = keyTimes()[index + 1];

Ditto.

> Source/WebCore/svg/SVGAnimationElement.cpp:432
> +    if (calcMode() == CalcMode::Discrete && keyTimes().size() == 2)

Ditto.

> Source/WebCore/svg/SVGAnimationElement.cpp:489
> +        fromPercent = keyTimes()[index];
> +        toPercent = keyTimes()[index + 1];

Ditto.

> Source/WebCore/svg/SVGAnimationElement.cpp:537
> +        && (hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) && hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) && (keyTimes().size() < 2 || keyTimes().size() != m_keyPoints.size())))

Ditto.

> Source/WebCore/svg/SVGAnimationElement.cpp:552
> +            && (calcMode == CalcMode::Discrete || !keyTimes().size() || keyTimes().last() == 1)

Ditto.

> Source/WebCore/svg/SVGAnimationElement.cpp:554
> +            && (!hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (keyTimes().size() > 1 && keyTimes().size() == m_keyPoints.size()));

Ditto.

> Source/WebCore/svg/SVGAnimationElement.cpp:560
> +        m_animationValid = calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (keyTimes().size() > 1 && keyTimes().size() == m_keyPoints.size());

Ditto.
Comment 3 Ryosuke Niwa 2021-04-12 18:42:47 PDT
*** Bug 222715 has been marked as a duplicate of this bug. ***
Comment 4 Said Abou-Hallawa 2021-04-12 20:12:33 PDT
Created attachment 425824 [details]
Patch
Comment 5 Said Abou-Hallawa 2021-04-13 00:34:07 PDT
Comment on attachment 425821 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=425821&action=review

> Source/WebCore/svg/SVGAnimationElement.cpp:-352
> -    Vector<float> keyTimesForPaced;

This is the reason of the assertions in some svg layout tests. Appending times directly into m_keyTimesForPaced allowed partial calculation. If one of the distances is zero this function will return with incomplete m_keyTimesForPaced. To fix these assertions we need to either set m_keyTimesForPaced to a complete list or an empty list.

> LayoutTests/svg/animations/animate-calcMode-paced-overwrite-key-times.html:10
> +      setTimeout(function() {

This test was failing on the EWS because of this setTimeout(). We need to add waitUntilDone()/notifyDone() to properly synchronize the test.
Comment 6 EWS 2021-04-13 01:05:33 PDT
Committed r275868 (236433@main): <https://commits.webkit.org/236433@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 425824 [details].
Comment 7 Radar WebKit Bug Importer 2021-04-13 01:06:15 PDT
<rdar://problem/76580027>