Backed out changeset 088d40fae53d (bug 1446346) for failing browser/components/resistfingerprinting/test/mochitest/test_reduce_time_precision.html on a CLOSED TREE
authorAndreea Pavel <apavel@mozilla.com>
Wed, 18 Apr 2018 23:51:19 +0300
changeset 467961 0e277eb0ce37b3fa09b321f991d72d07f5c4202a
parent 467960 05412fcc00a740e9a718dfbd34e1011007335423
child 467962 f93b12264c704d8779e00bbd635f66bfd50f7084
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1446346
milestone61.0a1
backs out088d40fae53da887d353577b5b855475a8617bf9
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
Backed out changeset 088d40fae53d (bug 1446346) for failing browser/components/resistfingerprinting/test/mochitest/test_reduce_time_precision.html on a CLOSED TREE
dom/media/webaudio/AudioContext.cpp
toolkit/components/resistfingerprinting/nsRFPService.cpp
toolkit/components/resistfingerprinting/nsRFPService.h
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -657,36 +657,35 @@ AudioContext::Graph() const
 MediaStream*
 AudioContext::DestinationStream() const
 {
   if (Destination()) {
     return Destination()->Stream();
   }
   return nullptr;
 }
+
 double
 AudioContext::CurrentTime()
 {
   MediaStream* stream = Destination()->Stream();
-  double rawTime = stream->StreamTimeToSeconds(stream->GetCurrentTime());
 
-  // CurrentTime increments in intervals of 128/sampleRate. If the Timer
-  // Precision Reduction is smaller than this interval, the jittered time
-  // can always be reversed to the raw step of the interval. In that case
-  // we can simply return the un-reduced time; and avoid breaking tests.
-  // We have to convert each variable into a common magnitude, we choose ms.
-  if ((128/mSampleRate) * 1000.0 > nsRFPService::TimerResolution() / 1000.0) {
-    return rawTime;
+  if (!mIsStarted &&
+    stream->StreamTimeToSeconds(stream->GetCurrentTime()) == 0) {
+      return 0;
   }
+
   // The value of a MediaStream's CurrentTime will always advance forward; it will never
   // reset (even if one rewinds a video.) Therefore we can use a single Random Seed
   // initialized at the same time as the object.
   return nsRFPService::ReduceTimePrecisionAsSecs(
-    rawTime, GetRandomTimelineSeed());
+    stream->StreamTimeToSeconds(stream->GetCurrentTime()),
+    GetRandomTimelineSeed());
 }
+
 void AudioContext::DisconnectFromOwner()
 {
   mIsDisconnecting = true;
   Shutdown();
   DOMEventTargetHelper::DisconnectFromOwner();
 }
 
 void
--- a/toolkit/components/resistfingerprinting/nsRFPService.cpp
+++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp
@@ -94,30 +94,33 @@ nsRFPService::GetOrCreate()
   if (!sInitialized) {
     sRFPService = new nsRFPService();
     nsresult rv = sRFPService->Init();
 
     if (NS_FAILED(rv)) {
       sRFPService = nullptr;
       return nullptr;
     }
+
     ClearOnShutdown(&sRFPService);
     sInitialized = true;
   }
+
   return sRFPService;
 }
-/* static */
-double
-nsRFPService::TimerResolution()
+
+inline double
+TimerResolution()
 {
   if(nsRFPService::IsResistFingerprintingEnabled()) {
     return max(100000.0, (double)sResolutionUSec);
   }
   return sResolutionUSec;
 }
+
 /* static */
 bool
 nsRFPService::IsResistFingerprintingEnabled()
 {
   return sPrivacyResistFingerprinting;
 }
 
 /* static */
--- a/toolkit/components/resistfingerprinting/nsRFPService.h
+++ b/toolkit/components/resistfingerprinting/nsRFPService.h
@@ -153,25 +153,27 @@ enum TimerPrecisionType {
   RFPOnly = 2
 };
 
 class nsRFPService final : public nsIObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
+
   static nsRFPService* GetOrCreate();
   static bool IsResistFingerprintingEnabled();
   static bool IsTimerPrecisionReductionEnabled(TimerPrecisionType aType);
-  static double TimerResolution();
+
   enum TimeScale {
     Seconds      = 1,
     MilliSeconds = 1000,
     MicroSeconds = 1000000
   };
+
   // The following Reduce methods can be called off main thread.
   static double ReduceTimePrecisionAsUSecs(
     double aTime,
     int64_t aContextMixin,
     TimerPrecisionType aType = TimerPrecisionType::All);
   static double ReduceTimePrecisionAsMSecs(
     double aTime,
     int64_t aContextMixin,