| Index: Source/platform/Timer.cpp
|
| diff --git a/Source/platform/Timer.cpp b/Source/platform/Timer.cpp
|
| index 796bc2cf95a4d569e80673e3ab5441f0a9ebacbd..7295542ee380a30e94c68d4dc566a03e93eb6896 100644
|
| --- a/Source/platform/Timer.cpp
|
| +++ b/Source/platform/Timer.cpp
|
| @@ -105,12 +105,7 @@ void TimerBase::setNextFireTime(double now, double delay)
|
| // TODO(skyostil): Move timer alignment into the scheduler.
|
| m_webScheduler->postTimerTaskAt(m_location, m_cancellableTimerTask, m_nextFireTime);
|
| } else {
|
| - // Round the delay up to the nearest millisecond to be consistant with the
|
| - // previous behavior of BlinkPlatformImpl::setSharedTimerFireInterval.
|
| - long long delayMs = static_cast<long long>(ceil((newTime - now) * 1000.0));
|
| - if (delayMs < 0)
|
| - delayMs = 0;
|
| - m_webScheduler->postTimerTask(m_location, m_cancellableTimerTask, delayMs);
|
| + m_webScheduler->postTimerTask(m_location, m_cancellableTimerTask, newTime - now);
|
| }
|
| }
|
| }
|
| @@ -126,10 +121,14 @@ void TimerBase::runInternal()
|
| TRACE_EVENT_SET_SAMPLING_STATE("blink", "BlinkInternal");
|
|
|
| m_nextFireTime = 0;
|
| - // Note: repeating timers drift, but this is preserving the functionality of the old timer heap.
|
| - // See crbug.com/328700.
|
| - if (m_repeatInterval)
|
| - setNextFireTime(monotonicallyIncreasingTime(), m_repeatInterval);
|
| + if (m_repeatInterval) {
|
| + double now = monotonicallyIncreasingTime();
|
| + ASSERT(now >= m_unalignedNextFireTime);
|
| + // This computation should be drift free, and it will cope if we miss a beat,
|
| + // which can easily happen if the thread is busy.
|
| + double intervalToNextFireTime = m_repeatInterval - fmod(now - m_unalignedNextFireTime, m_repeatInterval);
|
| + setNextFireTime(now, intervalToNextFireTime);
|
| + }
|
| fired();
|
| TRACE_EVENT_SET_SAMPLING_STATE("blink", "Sleeping");
|
| }
|
|
|