Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2356)

Unified Diff: Source/platform/Timer.cpp

Issue 1290633002: Revert of Fix the drift in repeating timers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/platform/TimerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/Timer.cpp
diff --git a/Source/platform/Timer.cpp b/Source/platform/Timer.cpp
index 7295542ee380a30e94c68d4dc566a03e93eb6896..796bc2cf95a4d569e80673e3ab5441f0a9ebacbd 100644
--- a/Source/platform/Timer.cpp
+++ b/Source/platform/Timer.cpp
@@ -105,7 +105,12 @@
// TODO(skyostil): Move timer alignment into the scheduler.
m_webScheduler->postTimerTaskAt(m_location, m_cancellableTimerTask, m_nextFireTime);
} else {
- m_webScheduler->postTimerTask(m_location, m_cancellableTimerTask, newTime - now);
+ // 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);
}
}
}
@@ -121,14 +126,10 @@
TRACE_EVENT_SET_SAMPLING_STATE("blink", "BlinkInternal");
m_nextFireTime = 0;
- 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);
- }
+ // 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);
fired();
TRACE_EVENT_SET_SAMPLING_STATE("blink", "Sleeping");
}
« no previous file with comments | « no previous file | Source/platform/TimerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698