Index: chrome/renderer/render_widget.cc |
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc |
index 96f33c912435d9478d6f0b9b1b7b5e37adce4ff1..f8cc1273c166222010d90724d38844c9f10580bb 100644 |
--- a/chrome/renderer/render_widget.cc |
+++ b/chrome/renderer/render_widget.cc |
@@ -483,40 +483,53 @@ void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, |
void RenderWidget::AnimationCallback() { |
animation_task_posted_ = false; |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AnimationDelayTime", 0, 0, 16, 17); |
+ if (!animation_update_pending_) |
+ return; |
+ if (!animation_floor_time_.is_null()) { |
+ // Record when we fired (according to base::Time::Now()) relative to when |
+ // we posted the task to quantify how much the base::Time/base::TimeTicks |
+ // skew is affecting animations. |
+ base::TimeDelta animation_callback_delay = base::Time::Now() - |
+ (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16)); |
+ UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime", |
+ animation_callback_delay, |
+ base::TimeDelta::FromMilliseconds(0), |
+ base::TimeDelta::FromMilliseconds(30), |
+ 25); |
+ } |
CallDoDeferredUpdate(); |
} |
void RenderWidget::AnimateIfNeeded() { |
- if (animation_update_pending_) { |
- base::Time now = base::Time::Now(); |
- if (now >= animation_floor_time_) { |
- animation_floor_time_ = now + base::TimeDelta::FromMilliseconds(16); |
- // Set a timer to call us back after 16ms (targetting 60FPS) before |
- // running animation callbacks so that if a callback requests another |
- // we'll be sure to run it at the proper time. |
- MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( |
- this, &RenderWidget::AnimationCallback), 16); |
- animation_task_posted_ = true; |
- animation_update_pending_ = false; |
- webwidget_->animate(); |
- } else if (!animation_task_posted_) { |
- // This code uses base::Time::Now() to calculate the floor and next fire |
- // time because javascript's Date object uses base::Time::Now(). The |
- // message loop uses base::TimeTicks, which on windows can have a |
- // different granularity than base::Time. |
- // The upshot of all this is that this function might be called before |
- // base::Time::Now() has advanced past the animation_floor_time_. To |
- // avoid exposing this delay to javascript, we keep posting delayed |
- // tasks until base::Time::Now() has advanced far enough. |
- int64 delay = (animation_floor_time_ - now).InMillisecondsRoundedUp(); |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AnimationDelayTime", |
- static_cast<int>(delay), 0, 16, 17); |
- animation_task_posted_ = true; |
- MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( |
- this, &RenderWidget::AnimationCallback), delay); |
- } |
+ if (!animation_update_pending_) |
+ return; |
+ base::Time now = base::Time::Now(); |
+ if (now >= animation_floor_time_) { |
+ animation_floor_time_ = now + base::TimeDelta::FromMilliseconds(16); |
+ // Set a timer to call us back after 16ms (targetting 60FPS) before |
+ // running animation callbacks so that if a callback requests another |
+ // we'll be sure to run it at the proper time. |
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( |
+ this, &RenderWidget::AnimationCallback), 16); |
+ animation_task_posted_ = true; |
+ animation_update_pending_ = false; |
+ webwidget_->animate(); |
+ return; |
} |
+ if (animation_task_posted_) |
+ return; |
+ // This code uses base::Time::Now() to calculate the floor and next fire |
+ // time because javascript's Date object uses base::Time::Now(). The |
+ // message loop uses base::TimeTicks, which on windows can have a |
+ // different granularity than base::Time. |
+ // The upshot of all this is that this function might be called before |
+ // base::Time::Now() has advanced past the animation_floor_time_. To |
+ // avoid exposing this delay to javascript, we keep posting delayed |
+ // tasks until base::Time::Now() has advanced far enough. |
+ int64 delay = (animation_floor_time_ - now).InMillisecondsRoundedUp(); |
+ animation_task_posted_ = true; |
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, |
+ NewRunnableMethod(this, &RenderWidget::AnimationCallback), delay); |
} |
void RenderWidget::CallDoDeferredUpdate() { |