Title: [215153] trunk/Source/WebCore
- Revision
- 215153
- Author
- simon.fra...@apple.com
- Date
- 2017-04-08 16:55:30 -0700 (Sat, 08 Apr 2017)
Log Message
Align the timers for throttled rAF to reduce power usage
https://bugs.webkit.org/show_bug.cgi?id=170630
rdar://problem/31490620
Reviewed by Chris Dumez.
Align the timers for all throttled ScriptedAnimationControllers in the process with
a resolution of 30ms, which reduces process wake-ups and thus saves power.
* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::scheduleAnimation):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (215152 => 215153)
--- trunk/Source/WebCore/ChangeLog 2017-04-08 23:19:16 UTC (rev 215152)
+++ trunk/Source/WebCore/ChangeLog 2017-04-08 23:55:30 UTC (rev 215153)
@@ -1,3 +1,17 @@
+2017-04-08 Simon Fraser <simon.fra...@apple.com>
+
+ Align the timers for throttled rAF to reduce power usage
+ https://bugs.webkit.org/show_bug.cgi?id=170630
+ rdar://problem/31490620
+
+ Reviewed by Chris Dumez.
+
+ Align the timers for all throttled ScriptedAnimationControllers in the process with
+ a resolution of 30ms, which reduces process wake-ups and thus saves power.
+
+ * dom/ScriptedAnimationController.cpp:
+ (WebCore::ScriptedAnimationController::scheduleAnimation):
+
2017-04-08 Chris Dumez <cdu...@apple.com>
Drop std::chrono support from Timer class
Modified: trunk/Source/WebCore/dom/ScriptedAnimationController.cpp (215152 => 215153)
--- trunk/Source/WebCore/dom/ScriptedAnimationController.cpp 2017-04-08 23:19:16 UTC (rev 215152)
+++ trunk/Source/WebCore/dom/ScriptedAnimationController.cpp 2017-04-08 23:55:30 UTC (rev 215153)
@@ -303,8 +303,18 @@
return;
Seconds animationInterval = interval();
- double scheduleDelay = std::max<double>(animationInterval.value() - (m_document->domWindow()->nowTimestamp() - m_lastAnimationFrameTimestamp), 0);
- m_animationTimer.startOneShot(scheduleDelay);
+
+ // FIXME: not ideal to snapshot time both in now() and nowTimestamp(), the latter of which also has reduced resolution.
+ MonotonicTime now = MonotonicTime::now();
+
+ MonotonicTime fireTime = now + std::max(animationInterval - Seconds(m_document->domWindow()->nowTimestamp() - m_lastAnimationFrameTimestamp), 0_s);
+ Seconds alignmentInterval = 30_ms;
+ // Snap to the nearest alignmentInterval.
+ Seconds alignment = (fireTime + alignmentInterval / 2) % alignmentInterval;
+ MonotonicTime alignedFireTime = fireTime - alignment;
+
+ m_animationTimer.startOneShot(alignedFireTime - now);
+
dispatchLoggingEventIfRequired("raf-schedule-animation-timer");
#else
if (FrameView* frameView = m_document->view())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes