Bug 1432429 - Clean up a few random areas of code to accomodate Fuzzyfox: Performance and RefreshDriver. r=froydnj,baku
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 18 Sep 2018 13:05:48 -0500
changeset 502404 b65a35258367e497ee8026513a4deb2a3f3124fa
parent 502403 b00e84c0233b17a1daf0feccf660580aa5fe2d30
child 502405 3d52af18f5c684e30d720941c811ea8bb5213626
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, baku
bugs1432429
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1432429 - Clean up a few random areas of code to accomodate Fuzzyfox: Performance and RefreshDriver. r=froydnj,baku 1: Correct the Performance API 'NowUnclamped' to obtain a non-Fuzzed Timestamp 2: Do not compare fuzzed and non-fuzzed timestamps in a Refresh Driver assert, since this happens so early on that we will eventually compare them and asserting would be bad.
dom/performance/Performance.cpp
layout/base/nsRefreshDriver.cpp
--- a/dom/performance/Performance.cpp
+++ b/dom/performance/Performance.cpp
@@ -104,17 +104,17 @@ Performance::Now()
   const double maxResolutionMs = 0.020;
   DOMHighResTimeStamp minimallyClamped = floor(rawTime / maxResolutionMs) * maxResolutionMs;
   return nsRFPService::ReduceTimePrecisionAsMSecs(minimallyClamped, GetRandomTimelineSeed());
 }
 
 DOMHighResTimeStamp
 Performance::NowUnclamped() const
 {
-  TimeDuration duration = TimeStamp::Now() - CreationTimeStamp();
+  TimeDuration duration = TimeStamp::NowUnfuzzed() - CreationTimeStamp();
   return duration.ToMilliseconds();
 }
 
 DOMHighResTimeStamp
 Performance::TimeOrigin()
 {
   if (!mPerformanceService) {
     mPerformanceService = PerformanceService::GetOrCreate();
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -25,16 +25,17 @@
 // to manually include it
 #include <mmsystem.h>
 #include "WinUtils.h"
 #endif
 
 #include "mozilla/AnimationEventDispatcher.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/AutoRestore.h"
+#include "mozilla/DebugOnly.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/dom/FontTableURIProtocolHandler.h"
 #include "nsITimer.h"
 #include "nsLayoutUtils.h"
 #include "nsPresContext.h"
 #include "nsComponentManagerUtils.h"
 #include "mozilla/Logging.h"
 #include "nsAutoPtr.h"
@@ -657,17 +658,20 @@ private:
         MonitorAutoLock lock(mRefreshTickLock);
         aVsyncTimestamp = mRecentVsync;
         mProcessedVsync = true;
       } else {
 
         mLastChildTick = TimeStamp::Now();
         mLastProcessedTickInChildProcess = aVsyncTimestamp;
       }
-      MOZ_ASSERT(aVsyncTimestamp <= TimeStamp::Now());
+
+      // Do not compare timestamps unless they are both canonical or fuzzy
+      DebugOnly<TimeStamp> rightnow = TimeStamp::Now();
+      MOZ_ASSERT_IF((*&rightnow).UsedCanonicalNow() == aVsyncTimestamp.UsedCanonicalNow(), aVsyncTimestamp <= *&rightnow);
 
       // We might have a problem that we call ~VsyncRefreshDriverTimer() before
       // the scheduled TickRefreshDriver() runs. Check mVsyncRefreshDriverTimer
       // before use.
       if (mVsyncRefreshDriverTimer) {
         RefPtr<VsyncRefreshDriverTimer> timer = mVsyncRefreshDriverTimer;
         timer->RunRefreshDrivers(aVsyncTimestamp);
         // Note: mVsyncRefreshDriverTimer might be null now.