Bug 1526328 - Disable Telemetry recording in FUZZING builds. r=janerik
authorChristian Holler <choller@mozilla.com>
Wed, 13 Feb 2019 16:16:32 +0000
changeset 458910 4441e86d56b9
parent 458909 dbf72abf5597
child 458911 6e651b1b00b1
push id35551
push usershindli@mozilla.com
push dateWed, 13 Feb 2019 21:34:09 +0000
treeherdermozilla-central@08f794a4928e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanerik
bugs1526328
milestone67.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 1526328 - Disable Telemetry recording in FUZZING builds. r=janerik Differential Revision: https://phabricator.services.mozilla.com/D19359
toolkit/components/telemetry/core/Telemetry.cpp
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/components/telemetry/core/Telemetry.cpp
+++ b/toolkit/components/telemetry/core/Telemetry.cpp
@@ -1101,22 +1101,24 @@ TelemetryImpl::GetCanRecordBase(bool* re
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::SetCanRecordBase(bool canRecord) {
   if (recordreplay::IsRecordingOrReplaying()) {
     return NS_OK;
   }
+#ifndef FUZZING
   if (canRecord != mCanRecordBase) {
     TelemetryHistogram::SetCanRecordBase(canRecord);
     TelemetryScalar::SetCanRecordBase(canRecord);
     TelemetryEvent::SetCanRecordBase(canRecord);
     mCanRecordBase = canRecord;
   }
+#endif
   return NS_OK;
 }
 
 /**
  * Indicates if Telemetry is allowed to record extended data. Returns false if
  * the user hasn't opted into "extended Telemetry" on the Release channel, when
  * the user has explicitly opted out of Telemetry on Nightly/Aurora/Beta or if
  * manually set to false during tests. If the returned value is false, gathering
@@ -1128,22 +1130,24 @@ TelemetryImpl::GetCanRecordExtended(bool
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::SetCanRecordExtended(bool canRecord) {
   if (recordreplay::IsRecordingOrReplaying()) {
     return NS_OK;
   }
+#ifndef FUZZING
   if (canRecord != mCanRecordExtended) {
     TelemetryHistogram::SetCanRecordExtended(canRecord);
     TelemetryScalar::SetCanRecordExtended(canRecord);
     TelemetryEvent::SetCanRecordExtended(canRecord);
     mCanRecordExtended = canRecord;
   }
+#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::GetCanRecordReleaseData(bool* ret) {
   *ret = mCanRecordBase;
   return NS_OK;
 }
@@ -1166,25 +1170,27 @@ TelemetryImpl::GetIsOfficialTelemetry(bo
 }
 
 already_AddRefed<nsITelemetry> TelemetryImpl::CreateTelemetryInstance() {
   MOZ_ASSERT(
       sTelemetry == nullptr,
       "CreateTelemetryInstance may only be called once, via GetService()");
 
   bool useTelemetry = false;
+#ifndef FUZZING
   if ((XRE_IsParentProcess() || XRE_IsContentProcess() || XRE_IsGPUProcess() ||
        XRE_IsSocketProcess()) &&
       // Telemetry is never accumulated when recording or replaying, both
       // because the resulting measurements might be biased and because
       // measurements might occur at non-deterministic points in execution
       // (e.g. garbage collections).
       !recordreplay::IsRecordingOrReplaying()) {
     useTelemetry = true;
   }
+#endif
 
   // Set current product (determines Fennec/GeckoView at runtime).
   SetCurrentProduct();
 
   // First, initialize the TelemetryHistogram and TelemetryScalar global states.
   TelemetryHistogram::InitializeGlobalState(useTelemetry, useTelemetry);
   TelemetryScalar::InitializeGlobalState(useTelemetry, useTelemetry);
 
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3782,28 +3782,31 @@ Result<bool, nsresult> XREMain::CheckLas
 int XREMain::XRE_mainStartup(bool* aExitFlag) {
   nsresult rv;
 
   if (!aExitFlag) return 1;
   *aExitFlag = false;
 
   SetShutdownChecks();
 
-  // Enable Telemetry IO Reporting on DEBUG, nightly and local builds
+  // Enable Telemetry IO Reporting on DEBUG, nightly and local builds,
+  // but disable it on FUZZING builds.
+#ifndef FUZZING
 #ifdef DEBUG
   mozilla::Telemetry::InitIOReporting(gAppData->xreDirectory);
 #else
   {
     const char* releaseChannel = NS_STRINGIFY(MOZ_UPDATE_CHANNEL);
     if (strcmp(releaseChannel, "nightly") == 0 ||
         strcmp(releaseChannel, "default") == 0) {
       mozilla::Telemetry::InitIOReporting(gAppData->xreDirectory);
     }
   }
 #endif /* DEBUG */
+#endif /* FUZZING */
 
 #if defined(XP_WIN)
   // Enable the HeapEnableTerminationOnCorruption exploit mitigation. We ignore
   // the return code because it always returns success, although it has no
   // effect on Windows older than XP SP3.
   HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
 #endif /* XP_WIN */