Closed
Bug 1246893
Opened 9 years ago
Closed 9 years ago
nsSMILKeySpline::GetSplineValue should return 0 or 1 on its boundaries
Categories
(Core :: SVG, defect)
Core
SVG
Tracking
()
RESOLVED
FIXED
mozilla47
Tracking | Status | |
---|---|---|
firefox47 | --- | fixed |
People
(Reporter: hiro, Unassigned)
References
Details
Attachments
(1 file)
For example, cubic-bezier(0, 1.5, 1. 1.5), GetSplineValue returns 1.000146 on 1.0. The error of the value is not acceptable to be used in automation tests.
Reporter | ||
Comment 1•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/34155/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/34155/
Attachment #8717365 -
Flags: review?(bbirtles)
Reporter | ||
Comment 2•9 years ago
|
||
I pushed a try with attachment 8717365 [details]. The patch seems harmless.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f793f79b3cad
Comment 3•9 years ago
|
||
That will make content that is invalid, valid. The SVG specification does not say to do that (although perhaps it should). Instead it says such splines are invalid. https://www.w3.org/TR/SVG/animate.html#KeySplinesAttribute
Reporter | ||
Comment 4•9 years ago
|
||
Thank you, Robert. Then we should limit the values in animation codes.
Reporter | ||
Updated•9 years ago
|
Attachment #8717365 -
Flags: review?(bbirtles)
Comment 5•9 years ago
|
||
Maybe Brian might consider changing the SVG animation specification.
Comment 6•9 years ago
|
||
(In reply to Robert Longson from comment #3)
> That will make content that is invalid, valid. The SVG specification does
> not say to do that (although perhaps it should). Instead it says such
> splines are invalid.
> https://www.w3.org/TR/SVG/animate.html#KeySplinesAttribute
We already allow y values outside the range [1,0] since this code is re-used by CSS animation which allows it. For SVG, I'm pretty sure we do the range checking when we parse the string:
https://dxr.mozilla.org/mozilla-central/rev/2dfb45d74f42d2a0010696f5fd47c7a7da94cedb/dom/smil/nsSMILParserUtils.cpp#529
Reporter | ||
Comment 7•9 years ago
|
||
Brian, thank you for pointing it out.
I found another use of GetSplineValue in AsyncScrollBase::PositionAt[1]
[1] https://dxr.mozilla.org/mozilla-central/rev/2dfb45d74f42d2a0010696f5fd47c7a7da94cedb/layout/generic/AsyncScrollBase.cpp#103
And it seems that the function there also produces values greater than 1 if user sets SmoothScrollCurrentVelocityWeighting to a sufficiently small value, say 1/100000000.
[2] https://dxr.mozilla.org/mozilla-central/rev/2dfb45d74f42d2a0010696f5fd47c7a7da94cedb/layout/generic/AsyncScrollBase.cpp#96
Although I don't think it becomes a problem in the real world, I think we should fix the errors on the both boundaries in GetSplineValue.
Reporter | ||
Updated•9 years ago
|
Attachment #8717365 -
Flags: review?(bbirtles)
Comment 8•9 years ago
|
||
Comment on attachment 8717365 [details]
MozReview Request: Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r?birtles
https://reviewboard.mozilla.org/r/34155/#review31487
Looks good although I'm also a little curious as to the nature of the error. There is some approximation performed by nsSMILKeySpline but I thought it would be ok at the boundaries.
Attachment #8717365 -
Flags: review?(bbirtles) → review+
Reporter | ||
Comment 9•9 years ago
|
||
(In reply to Brian Birtles (:birtles) from comment #8)
> Comment on attachment 8717365 [details]
> MozReview Request: Bug 1246893 - Fix boundary values of
> nsSMILKeySpline::GetSplineValue. r?birtles
>
> https://reviewboard.mozilla.org/r/34155/#review31487
>
> Looks good although I'm also a little curious as to the nature of the error.
> There is some approximation performed by nsSMILKeySpline but I thought it
> would be ok at the boundaries.
Thank you, Brian! Your concerns and curious are always very keen. I should have dug into the source of the errors.
The errors actually come from guessForT in nsSMILKeySpline::GetTForX [1] because |intervalStart + dist * kSampleStepSize| != 1.0 in case of aX == 1.0.
[1] https://dxr.mozilla.org/mozilla-central/rev/e355cacefc881ba360d412853b57e8e060e966f4/dom/smil/nsSMILKeySpline.cpp#92
I will post a revised patch soon.
Reporter | ||
Comment 10•9 years ago
|
||
Comment on attachment 8717365 [details]
MozReview Request: Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r?birtles
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/34155/diff/1-2/
Attachment #8717365 -
Attachment description: MozReview Request: Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetSplineValue. r?birtles → MozReview Request: Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r?birtles
Reporter | ||
Comment 11•9 years ago
|
||
Comment on attachment 8717365 [details]
MozReview Request: Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r?birtles
I can't re-request review on MozReview.
A try:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=3fc6e2840034
Attachment #8717365 -
Flags: review+ → review?(bbirtles)
Comment 12•9 years ago
|
||
Comment on attachment 8717365 [details]
MozReview Request: Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r?birtles
https://reviewboard.mozilla.org/r/34155/#review31571
::: dom/smil/nsSMILKeySpline.cpp:80
(Diff revision 2)
> + // so we return 1.0 here to avoid the errors.
Nit: s/calcuration/calculation/
Just curious, where does the error come from? Is it due to the values we store in mSampleValues?
i.e. If we make nsSMILKeySpline::CalcSampleValues simply set mSampleValues[kSplineTableSize-1] = 1.0, would that fix this?
Attachment #8717365 -
Flags: review?(bbirtles)
Reporter | ||
Comment 13•9 years ago
|
||
(In reply to Brian Birtles (:birtles) from comment #12)
> Comment on attachment 8717365 [details]
> MozReview Request: Bug 1246893 - Fix boundary values of
> nsSMILKeySpline::GetTForX. r?birtles
>
> https://reviewboard.mozilla.org/r/34155/#review31571
>
> ::: dom/smil/nsSMILKeySpline.cpp:80
> (Diff revision 2)
> > + // so we return 1.0 here to avoid the errors.
>
> Nit: s/calcuration/calculation/
>
> Just curious, where does the error come from? Is it due to the values we
> store in mSampleValues?
>
> i.e. If we make nsSMILKeySpline::CalcSampleValues simply set
> mSampleValues[kSplineTableSize-1] = 1.0, would that fix this?
Unfortunately, no.
The error comes from just a result of summation.
An example code:
int
main(int argc, char *argv[])
{
int i;
double sum = 0;
for (i = 0; i < 10; i++) {
sum += 0.1;
}
printf("sum = %e\n", sum);
if (sum == 1.0) {
printf("Equals!\n");
}
return 0;
}
I can not see 'Equals' with gcc-4.8.4.
Updated•9 years ago
|
Attachment #8717365 -
Flags: review+
Comment 14•9 years ago
|
||
Comment on attachment 8717365 [details]
MozReview Request: Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r?birtles
https://reviewboard.mozilla.org/r/34155/#review31611
::: dom/smil/nsSMILKeySpline.cpp:80
(Diff revision 2)
> + // so we return 1.0 here to avoid the errors.
// Early return when aX == 1.0 to avoid floating-point inaccuracies.
Reporter | ||
Comment 15•9 years ago
|
||
Comment on attachment 8717365 [details]
MozReview Request: Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r?birtles
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/34155/diff/2-3/
Reporter | ||
Comment 16•9 years ago
|
||
Keywords: checkin-needed
Comment 17•9 years ago
|
||
Keywords: checkin-needed
Comment 18•9 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
You need to log in
before you can comment on or make changes to this bug.
Description
•