Closed Bug 825254 Opened 12 years ago Closed 9 months ago

SMIL animateMotion fails to stay on path when the path itself is SMIL-animated

Categories

(Core :: SVG, defect)

defect

Tracking

()

RESOLVED FIXED
117 Branch
Tracking Status
firefox117 --- fixed

People

(Reporter: david.dailey, Assigned: longsonr)

References

(Blocks 1 open bug)

Details

Attachments

(3 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
Build ID: 20121128204232

Steps to reproduce:

http://granite.sru.edu/~ddailey/svg/animoval8b.svg
or
http://cs.sru.edu/~ddailey/svg/animpath3.svg 


Actual results:

The moving object does not stay on the path as the path moves.


Expected results:

It should stay on the path. It does so in Opera, Chrome and Safari.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Hardware: x86_64 → All
Version: 17 Branch → Trunk
Is this a duplicate of bug 665392
Nope. An un-bitrotted version of that bug's patch doesn't seem to have any effect on this bug's testcases (but still fixes its own testcase).

I think the bug here is that we're working with the <path>'s base value, rather than its animated value, or something like that.
Attached image testcase 1
Here's a reduced testcase.
Attachment #696584 - Attachment description: testcase demonstrating that this works correctly w/ JS tweaks → reference testcase (w/ JS tweaks)
OK -- so we cache the flattened path in SVGMotionSMILAnimationFunction::mPath, and we track whether we need to update our cached flattened path with "mIsPathStale".

When the <path> element changes due to scripted modifications (as in "reference testcase"), we end up toggling mIsPathStale because the <mpath> element is a mutation observer on the <path> element, and it receives a call to AttributeChanged.

However, when the path is modified by SMIL animation (as in comment 0's URLs and my attached "testcase 1"), we don't get a mutation notification for some reason.
Yeah, looks like the path's frame is the only thing that receives a notification "d" is animated.

SVGAnimatedPathSegList::SetAnimValue() calls "aElement->DidAnimatePathSegList()"...
https://mxr.mozilla.org/mozilla-central/source/content/svg/content/src/SVGAnimatedPathSegList.cpp#123
...which just calls AttributeChanged on our frame, if we have a frame:
https://mxr.mozilla.org/mozilla-central/source/content/svg/content/src/nsSVGElement.cpp#1964
Summary: SVG animation fails to stay on curve when curve is animated → SMIL animateMotion fails to stay on path when the path itself is SMIL-animated
Attached patch WIP (obsolete) — Splinter Review
This makes DidAnimatePathSegList() fire AttributeChanged notifications to all listeners, not just to the frame.

That's probably overkill (and may have undesirable effects), so this isn't a finished patch, but it fixes all of the attached testcases (though it seems to cause some occasional weird flickering of the paths in the first URL from comment 0, for "animoval8b.svg").
I think a better approach is that mpath shouldn't use a mutation observer, it should use an nsSVGRenderingObserver instead.
Would that work even if the <path> is "display:none", though?
Another instance of this :
http://srufaculty.sru.edu/david.dailey/svg/bezierovals.svg
Am hoping to develop several new things using this based on http://srufaculty.sru.edu/david.dailey/cs337/follow.svg for upcoming presentations, so hope ya'll can work on it. cheers
D
It is interesting to note that animating the stroke-dasharray works fine in Firefox when the path is animated -- seems like the underlying logic in the browser might be somehow related since pathLength varies dynamically
http://cs.sru.edu/~ddailey/tangles/AnimTangleStroke.svg
and http://cs.sru.edu/~ddailey/tangles/tangleAnimStrokeAndPath.svg (latter may be more understandable, but former is simpler).
Severity: normal → S3
Assignee: nobody → longsonr
Status: NEW → ASSIGNED
Attachment #696588 - Attachment is obsolete: true
Pushed by longsonr@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/77043dead023
SMIL animateMotion should react to the path itself being animated r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/41015 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 117 Branch
Upstream PR merged by moz-wptsync-bot
Depends on: 1752912
Blocks: 738574
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: