Skip to content

Conversation

@mscottapple
Copy link
Contributor

@mscottapple mscottapple commented Apr 18, 2024

53e67f6

REGRESSION(277450@main): OOB array read with SVG animation where keyPoints = 0.
https://bugs.webkit.org/show_bug.cgi?id=272929
rdar://126636733

Reviewed by Said Abou-Hallawa.

This change makes a couple additional, similar changes to the original changes
to better track the SVG spec. (See the original bug for more information.)

* LayoutTests/svg/animations/animate-zero-keyPoints-should-not-crash-expected.txt: Added.
* LayoutTests/svg/animations/animate-zero-keyPoints-should-not-crash.html: Added.
* Source/WebCore/svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::keyTimes const):
(WebCore::SVGAnimationElement::startedActiveInterval):

Canonical link: https://commits.webkit.org/278212@main

c1a7f24

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ❌ 🧪 mac-wk1 ✅ 🛠 wpe-skia
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 tv ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
loading 🛠 tv-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 watch
✅ 🛠 watch-sim

@mscottapple mscottapple self-assigned this Apr 18, 2024
@mscottapple mscottapple added the SVG For bugs in the SVG implementation. label Apr 18, 2024
@mscottapple
Copy link
Contributor Author

Added people involved with the change that introduced this crash.

@mscottapple mscottapple force-pushed the eng/OOB-array-read-with-SVG-animation-where-keyPoints--0 branch from bbc0bf7 to c55c930 Compare April 19, 2024 00:05
@shallawa
Copy link
Contributor

Please include the blamed revision 277450@main in the title of the commit message.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Apr 19, 2024
@mscottapple mscottapple removed the merging-blocked Applied to prevent a change from being merged label Apr 22, 2024
@mscottapple mscottapple changed the title Fix an OOB array read with SVG animation where keyPoints = 0. REGRESSION(277450@main): OOB array read with SVG animation where keyPoints = 0. Apr 22, 2024
@mscottapple mscottapple force-pushed the eng/OOB-array-read-with-SVG-animation-where-keyPoints--0 branch from c55c930 to 01ff56b Compare April 22, 2024 21:14
@mscottapple mscottapple requested a review from shallawa April 23, 2024 00:06
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Apr 23, 2024
@mscottapple mscottapple removed the merging-blocked Applied to prevent a change from being merged label Apr 23, 2024
@mscottapple mscottapple force-pushed the eng/OOB-array-read-with-SVG-animation-where-keyPoints--0 branch from 01ff56b to caa2678 Compare April 23, 2024 17:55
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Apr 23, 2024
@mscottapple mscottapple removed the merging-blocked Applied to prevent a change from being merged label Apr 23, 2024
@mscottapple mscottapple force-pushed the eng/OOB-array-read-with-SVG-animation-where-keyPoints--0 branch from caa2678 to a4cea47 Compare April 23, 2024 23:26
@mscottapple mscottapple requested a review from shallawa April 23, 2024 23:30
@mscottapple mscottapple force-pushed the eng/OOB-array-read-with-SVG-animation-where-keyPoints--0 branch from a4cea47 to 7b6d1a4 Compare April 24, 2024 00:09
@mscottapple mscottapple requested a review from shallawa April 24, 2024 00:21
@shallawa
Copy link
Contributor

Please change the commit message to describe correctly the current change.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Apr 24, 2024
@mscottapple
Copy link
Contributor Author

Now the test imported/w3c/web-platform-tests/svg/animations/animateMotion-keyPoints-001.html is failing with assert_equals: y position expected 0 but got -50

@shallawa
Copy link
Contributor

I think the specs is clear about the animateMotion overriding rules for the motion path and the overriding rules for the keyPoints.

But I think it is not clear about the overriding rules for the keyTimes when the calcMode is Paced and the animationMode is Path. When calcMode is Paced we usually use the values attribute to generate interpolated values for keyTimes. But with animationMode equal to Path I think values should be ignored in this case. And I would expect if calcMode is Paced and animationMode is Path is to have the attribute keyTimes specified in the <animateMotion> tag.

This is consistent with our code. In SVGAnimationElement::calculatePercentFromKeyPoints() we use m_keyTimesFromAttribute and not m_keyTimesForPaced as the working keyTimes. Look for where calculatePercentFromKeyPoints() is called. You will find it is called only if (calcMode != CalcMode::Paced || animationMode == AnimationMode::Path)

So to fix this issue, you will need to add this change to your patch.

const Vector<float>& SVGAnimationElement::keyTimes() const
{
    return calcMode() != CalcMode::Paced || animationMode() == AnimationMode::Path ? m_keyTimesFromAttribute : m_keyTimesForPaced;
}

@SupaYo
Copy link

SupaYo commented Apr 24, 2024

What do I have to do to fix the problem?

@mscottapple mscottapple removed the merging-blocked Applied to prevent a change from being merged label Apr 30, 2024
@mscottapple mscottapple force-pushed the eng/OOB-array-read-with-SVG-animation-where-keyPoints--0 branch from 7b6d1a4 to cd30bd5 Compare April 30, 2024 19:42
@mscottapple mscottapple force-pushed the eng/OOB-array-read-with-SVG-animation-where-keyPoints--0 branch from cd30bd5 to c1a7f24 Compare April 30, 2024 22:48
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 1, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: There is no need for the parentheses. The operator precedence should work as expected:

  1. The equality != and ==
  2. The logical &&
  3. The ternary conditional ? :

@shallawa shallawa added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels May 1, 2024
…oints = 0.

https://bugs.webkit.org/show_bug.cgi?id=272929
rdar://126636733

Reviewed by Said Abou-Hallawa.

This change makes a couple additional, similar changes to the original changes
to better track the SVG spec. (See the original bug for more information.)

* LayoutTests/svg/animations/animate-zero-keyPoints-should-not-crash-expected.txt: Added.
* LayoutTests/svg/animations/animate-zero-keyPoints-should-not-crash.html: Added.
* Source/WebCore/svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::keyTimes const):
(WebCore::SVGAnimationElement::startedActiveInterval):

Canonical link: https://commits.webkit.org/278212@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/OOB-array-read-with-SVG-animation-where-keyPoints--0 branch from c1a7f24 to 53e67f6 Compare May 1, 2024 17:08
@webkit-commit-queue
Copy link
Collaborator

Committed 278212@main (53e67f6): https://commits.webkit.org/278212@main

Reviewed commits have been landed. Closing PR #27481 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 53e67f6 into WebKit:main May 1, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 1, 2024
@mscottapple mscottapple deleted the eng/OOB-array-read-with-SVG-animation-where-keyPoints--0 branch May 1, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SVG For bugs in the SVG implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants