WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
94756
Fix a operator ordering bug in SVGSMILElement::calculateAnimationPercentAndRepeat
https://bugs.webkit.org/show_bug.cgi?id=94756
Summary
Fix a operator ordering bug in SVGSMILElement::calculateAnimationPercentAndRe...
Nico Weber
Reported
2012-08-22 16:33:48 PDT
Fix a operator ordering bug in SVGSMILElement::calculateAnimationPercentAndRepeat
Attachments
Patch
(2.23 KB, patch)
2012-08-22 16:35 PDT
,
Nico Weber
no flags
Details
Formatted Diff
Diff
Patch
(2.13 KB, patch)
2012-09-09 01:46 PDT
,
Nico Weber
no flags
Details
Formatted Diff
Diff
Patch
(2.18 KB, patch)
2012-09-09 02:59 PDT
,
Nico Weber
no flags
Details
Formatted Diff
Diff
Patch
(2.20 KB, patch)
2012-09-10 18:24 PDT
,
Nico Weber
no flags
Details
Formatted Diff
Diff
Patch
(2.00 KB, patch)
2012-10-26 15:59 PDT
,
Nico Weber
no flags
Details
Formatted Diff
Diff
Patch
(2.13 KB, patch)
2012-10-26 16:05 PDT
,
Nico Weber
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Nico Weber
Comment 1
2012-08-22 16:35:53 PDT
Created
attachment 160032
[details]
Patch
Eric Seidel (no email)
Comment 2
2012-08-23 11:08:00 PDT
Can we test this?
Stephen Chenney
Comment 3
2012-08-23 11:33:05 PDT
Comment on
attachment 160032
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=160032&action=review
> Source/WebCore/svg/animation/SVGSMILElement.cpp:969 > repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value());
I would propose avoiding the fmod entirely. It apparently is being used to determine if the fractional amount of repeatingDuration.value() / simpleDuration.value() is zero. Instead: float repeatFloat = repeatingDuration.value() / simpleDuration.value(); repeat = static_cast<unsigned>(repeatFloat); if (!(repeatFloat - repeat)) repeat--; No idea how to test it.
Nico Weber
Comment 4
2012-08-27 14:04:55 PDT
(In reply to
comment #3
)
> (From update of
attachment 160032
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=160032&action=review
> > > Source/WebCore/svg/animation/SVGSMILElement.cpp:969 > > repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value()); > > I would propose avoiding the fmod entirely. It apparently is being used to determine if the fractional amount of repeatingDuration.value() / simpleDuration.value() is zero. Instead: > float repeatFloat = repeatingDuration.value() / simpleDuration.value(); > repeat = static_cast<unsigned>(repeatFloat); > if (!(repeatFloat - repeat)) > repeat--;
How is that simpler than what's currently there?
Stephen Chenney
Comment 5
2012-08-27 14:10:15 PDT
(In reply to
comment #4
)
> (In reply to
comment #3
) > > (From update of
attachment 160032
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=160032&action=review
> > > > > Source/WebCore/svg/animation/SVGSMILElement.cpp:969 > > > repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value()); > > > > I would propose avoiding the fmod entirely. It apparently is being used to determine if the fractional amount of repeatingDuration.value() / simpleDuration.value() is zero. Instead: > > float repeatFloat = repeatingDuration.value() / simpleDuration.value(); > > repeat = static_cast<unsigned>(repeatFloat); > > if (!(repeatFloat - repeat)) > > repeat--; > > How is that simpler than what's currently there?
It's not really simpler, but it does less work, I think, and does not have numerical accuracy issues. Actually, this is probably better: float repeatFloat = repeatingDuration.value() / simpleDuration.value(); repeat = static_cast<unsigned>(repeatFloat); if (repeatFloat == repeat) repeat--;
Nico Weber
Comment 6
2012-08-27 14:19:23 PDT
> > How is that simpler than what's currently there? > > It's not really simpler, but it does less work, I think, and does not have > numerical accuracy issues. Actually, this is probably better: > > float repeatFloat = repeatingDuration.value() / simpleDuration.value(); > repeat = static_cast<unsigned>(repeatFloat); > if (repeatFloat == repeat) > repeat--;
I don't think this is performance-sensitive code. I would assume that fmod is at least as smart as any reimplementation we attempt to do.
Hans Wennborg
Comment 7
2012-09-07 07:06:52 PDT
***
Bug 96093
has been marked as a duplicate of this bug. ***
Nico Weber
Comment 8
2012-09-07 09:35:56 PDT
This is blocking our next clang roll. Can this go in? The alternative is to disable this new warning for webkit.
Philip Rogers
Comment 9
2012-09-07 09:41:28 PDT
(In reply to
comment #8
)
> This is blocking our next clang roll. Can this go in? The alternative is to disable this new warning for webkit.
I think it's fine to go in, but you'll have to find an r+ somewhere else.
Dirk Schulze
Comment 10
2012-09-08 19:46:53 PDT
Comment on
attachment 160032
[details]
Patch I would be in favor of doing it better from the beginning.
Nico Weber
Comment 11
2012-09-09 01:46:05 PDT
Created
attachment 162986
[details]
Patch
Early Warning System Bot
Comment 12
2012-09-09 01:52:34 PDT
Comment on
attachment 162986
[details]
Patch
Attachment 162986
[details]
did not pass qt-ews (qt): Output:
http://queues.webkit.org/results/13794495
Peter Beverloo (cr-android ews)
Comment 13
2012-09-09 01:54:11 PDT
Comment on
attachment 162986
[details]
Patch
Attachment 162986
[details]
did not pass cr-android-ews (chromium-android): Output:
http://queues.webkit.org/results/13788812
Early Warning System Bot
Comment 14
2012-09-09 01:54:26 PDT
Comment on
attachment 162986
[details]
Patch
Attachment 162986
[details]
did not pass qt-wk2-ews (qt): Output:
http://queues.webkit.org/results/13794496
WebKit Review Bot
Comment 15
2012-09-09 02:00:44 PDT
Comment on
attachment 162986
[details]
Patch
Attachment 162986
[details]
did not pass chromium-ews (chromium-xvfb): Output:
http://queues.webkit.org/results/13797410
Nico Weber
Comment 16
2012-09-09 02:59:28 PDT
Created
attachment 162988
[details]
Patch
Dirk Schulze
Comment 17
2012-09-09 07:04:59 PDT
Comment on
attachment 162988
[details]
Patch Well, wait. Instead of fixing the bug you surround it with a flag? Don't think that this is a good idea.
Nico Weber
Comment 18
2012-09-09 18:38:16 PDT
(In reply to
comment #17
)
> (From update of
attachment 162988
[details]
) > Well, wait. Instead of fixing the bug you surround it with a flag? Don't think that this is a good idea.
The fix was in the first patch, which was rejected as far as I understand due to lack of test (which is reasonable). So, here's the background: We update clang in chromium every 1-2 weeks. Every now and then, clang has a new warning, and we need to make sure all our code compiles with that new warning (we build with -Werror). If the warning is noisy, we just disable it globally, but since the clang people have a very reasonable warning policy, this happens rarely. This specific warning warns when someone writes `if (f(a, b, c > 0))` if they meant to write `if (f(a, b, c) > 0)` (see
http://permalink.gmane.org/gmane.comp.compilers.clang.scm/55995
for more information if you're curious). This is exactly what happened here, see the ChangeLog entry in the first patch for more information, where I looked at the history of this file. I had hoped that the original author of this code (anttik) would chime in. Maybe he's on vacation, or busy with other things. I'm not familiar with the svg code, and I currently don't have time to work on a test. (Someone familiar with the svg code mentioned earlier on this bug that it's not obvious how to test this.) I do want to update clang in chromium though, so I need some way forward. I could disable this new warning for all of chrome, but then it won't catch new bugs that it could prevent. I could disable it just for webkit's svg gyp target, but then it won't prevent new bugs it could've prevented in the svg code (also, if someone who didn't use gyp used a new clang, they'd get this warning, and they might even fix this the wrong way -- see e.g.
bug 96093
). So suppressing the warning just locally in this file seems like the best way forward to me. Let me know if you still disagree, then I'll disable it somewhere further up the stack.
Dirk Schulze
Comment 19
2012-09-10 17:16:41 PDT
Comment on
attachment 162988
[details]
Patch (In reply to
comment #18
)
> Let me know if you still disagree, then I'll disable it somewhere further up the stack.
I just asked you to address the code suggestions from stephen. Adding ifdef's is not a good solution at all, especially when you can easily fix it. r- because of ifdef instead of fixing the problem. It is ok not to add a test, since it is build system related IMO.
Nico Weber
Comment 20
2012-09-10 18:24:16 PDT
Created
attachment 163260
[details]
Patch
Nico Weber
Comment 21
2012-09-10 18:25:48 PDT
Back to patch set 1 then. As mentioned above, I don't think Stephen's suggestion make the code better. I'm happy to do the changes he's asking for in a follow-up patch if he really likes to see them. In this patch, I just want to fix a compiler warning and put the code in the form the original author intended. (See the ChangeLog entry.)
Dirk Schulze
Comment 22
2012-09-10 21:46:49 PDT
Our project goal is to clean up code that we touch. The second code suggestion from Stephen looks good to me.
Nico Weber
Comment 23
2012-09-10 21:48:03 PDT
It looks worse to me. I'm happy to discuss this on irc (thakis). I'm about to globally disable the warning instead:
http://codereview.chromium.org/10917180/
James Robinson
Comment 24
2012-09-10 23:03:38 PDT
Comment on
attachment 163260
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=163260&action=review
> Source/WebCore/svg/animation/SVGSMILElement.cpp:969 > repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value());
Due to this line it's fairly safe to assume simpleDuration.value() is not zero...
> Source/WebCore/svg/animation/SVGSMILElement.cpp:-970 > - if (fmod(repeatingDuration.value(), !simpleDuration.value()))
so !simpleDuration.value() simplifies to false which means this can be simplified to: if (fmodf(repeatingDuration.value(), 0)) which according to man fmodf raises a floating point exception and returns NaN so I'm guessing this code is somehow not reachable at all in practice. perhaps we can just nuke this whole if
Stephen Chenney
Comment 25
2012-09-11 07:31:05 PDT
(In reply to
comment #24
)
> (From update of
attachment 163260
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=163260&action=review
> > > Source/WebCore/svg/animation/SVGSMILElement.cpp:969 > > repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value()); > > Due to this line it's fairly safe to assume simpleDuration.value() is not zero...
simpleDuration.value() is not zero. That is checked for at the beginning of the method.
> > Source/WebCore/svg/animation/SVGSMILElement.cpp:-970 > > - if (fmod(repeatingDuration.value(), !simpleDuration.value())) > > so !simpleDuration.value() simplifies to false which means this can be simplified to: > > if (fmodf(repeatingDuration.value(), 0)) > > which according to man fmodf raises a floating point exception and returns NaN > > so I'm guessing this code is somehow not reachable at all in practice. perhaps we can just nuke this whole if
I believe that the code is intended to catch the case where the repeatingDuration is an exact multiple of the simpleDuration, in which case we need to add one to the repeat count. It might be possible to hit it with a test - I can try in my quiet moments today.
Nico Weber
Comment 26
2012-10-26 15:59:11 PDT
Created
attachment 171036
[details]
Patch
James Robinson
Comment 27
2012-10-26 16:02:41 PDT
Comment on
attachment 171036
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=171036&action=review
> Source/WebCore/svg/animation/SVGSMILElement.cpp:1006 > repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value()); > - if (fmod(repeatingDuration.value(), !simpleDuration.value())) > - repeat--; > + repeat--;
fold into the line above?
Nico Weber
Comment 28
2012-10-26 16:05:15 PDT
(In reply to
comment #27
)
> (From update of
attachment 171036
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=171036&action=review
> > > Source/WebCore/svg/animation/SVGSMILElement.cpp:1006 > > repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value()); > > - if (fmod(repeatingDuration.value(), !simpleDuration.value())) > > - repeat--; > > + repeat--; > > fold into the line above?
Done. (Didn't do it for somewhat nicer blame output, but meh)
Nico Weber
Comment 29
2012-10-26 16:05:29 PDT
Created
attachment 171037
[details]
Patch
Dirk Schulze
Comment 30
2012-10-26 16:15:45 PDT
Comment on
attachment 171037
[details]
Patch r=me
Nico Weber
Comment 31
2012-10-26 16:18:24 PDT
Comment on
attachment 171037
[details]
Patch Thanks!
WebKit Review Bot
Comment 32
2012-10-26 18:20:45 PDT
Comment on
attachment 171037
[details]
Patch Clearing flags on attachment: 171037 Committed
r132715
: <
http://trac.webkit.org/changeset/132715
>
WebKit Review Bot
Comment 33
2012-10-26 18:20:52 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug