Skip to content

Commit

Permalink
DevTools: Fix rounding error in animation startTime calculations.
Browse files Browse the repository at this point in the history
The test was flaky because of the rounding errors.

BUG=856955

Change-Id: I089ff4efa05935433c6f1cd3a89f8cbad26879d5
Reviewed-on: https://chromium-review.googlesource.com/1123768
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572265}
  • Loading branch information
a1ph authored and Commit Bot committed Jul 3, 2018
1 parent 331acd0 commit cb297d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
3 changes: 0 additions & 3 deletions third_party/WebKit/LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -4729,9 +4729,6 @@ crbug.com/856601 [ Linux ] fast/css/visited-link-hang.html [ Pass Timeout ]
crbug.com/856601 [ Linux ] http/tests/devtools/elements/styles-4/styles-inline-element-style-changes-should-not-force-style-recalc.js [ Pass Timeout ]
crbug.com/856601 [ Linux ] virtual/feature-policy-permissions/external/wpt/mediacapture-streams/MediaDevices-IDL-enumerateDevices.html [ Pass Timeout ]

# Sheriff 2018-06-27
crbug.com/856955 [ Win10 Linux ] inspector-protocol/animation/animation-multiple-frames.js [ Failure Pass ]

# Sheriff 2018-06-28
crbug.com/857520 [ Mac Win ] external/wpt/accelerometer/Accelerometer-iframe-access.https.html [ Failure ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
if (!lastStartTime || animation.startTime >= lastStartTime)
testRunner.log('Animation started: start time is valid');
else if (lastStartTime)
testRunner.log('Animation started: invalid startTime!' + animation.startTime + '.' + lastStartTime);
testRunner.log(`Animation started: invalid startTime: ${animation.startTime} < ${lastStartTime}`);
lastStartTime = animation.startTime;
numberAnimationsCaptured++;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,16 +547,18 @@ DocumentTimeline& InspectorAnimationAgent::ReferenceTimeline() {

double InspectorAnimationAgent::NormalizedStartTime(
blink::Animation& animation) {
double time_ms = animation.startTime().value_or(NullValue());
if (ReferenceTimeline().PlaybackRate() == 0) {
return animation.startTime().value_or(NullValue()) +
ReferenceTimeline().currentTime() -
animation.TimelineInternal()->currentTime();
time_ms += ReferenceTimeline().currentTime() -
animation.TimelineInternal()->currentTime();
} else {
time_ms += (animation.TimelineInternal()->ZeroTime() -
ReferenceTimeline().ZeroTime())
.InMillisecondsF() *
ReferenceTimeline().PlaybackRate();
}
return animation.startTime().value_or(NullValue()) +
(animation.TimelineInternal()->ZeroTime() -
ReferenceTimeline().ZeroTime())
.InMillisecondsF() *
ReferenceTimeline().PlaybackRate();
// Round to the closest microsecond.
return std::round(time_ms * 1000) / 1000;
}

void InspectorAnimationAgent::Trace(blink::Visitor* visitor) {
Expand Down

0 comments on commit cb297d9

Please sign in to comment.