Backed out 2 changesets (bug 1358372) for leaks in many tests. a=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 14 Feb 2018 20:37:30 +0200
changeset 454862 aec659045f35f04f7d9ac319665d640a2ccd0a88
parent 454861 6ca6a81f6f32e1e168ceec1a2f09766d9222bfe2
child 454863 b4a0dd02e4eacf5e840c3ce51a3d45aeb80d1d9b
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1358372
milestone59.0
backs out444056446ee9c8c6c3c9a3471e4d68432881aa98
e9139fb87c850c1006ca03b5cb41443c0ed06a8c
Backed out 2 changesets (bug 1358372) for leaks in many tests. a=backout Backed out changeset 444056446ee9 (bug 1358372) Backed out changeset e9139fb87c85 (bug 1358372)
accessible/ipc/win/HandlerProvider.h
dom/ipc/ContentParent.cpp
widget/windows/AudioSession.cpp
--- a/accessible/ipc/win/HandlerProvider.h
+++ b/accessible/ipc/win/HandlerProvider.h
@@ -10,17 +10,16 @@
 #include "mozilla/a11y/AccessibleHandler.h"
 #include "mozilla/AlreadyAddRefed.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/mscom/IHandlerProvider.h"
 #include "mozilla/mscom/Ptr.h"
 #include "mozilla/mscom/StructStream.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/UniquePtr.h"
-#include "HandlerData.h"
 
 struct NEWEST_IA2_INTERFACE;
 
 namespace mozilla {
 
 namespace mscom {
 
 class StructToStream;
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2376,27 +2376,16 @@ ContentParent::InitInternal(ProcessPrior
     for (StyleSheet* sheet :
            *sheetService->AuthorStyleSheets(StyleBackendType::Gecko)) {
       URIParams uri;
       SerializeURI(sheet->GetSheetURI(), uri);
       Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
     }
   }
 
-#if defined(XP_WIN)
-  // Send the info needed to join the browser process's audio session.
-  nsID id;
-  nsString sessionName;
-  nsString iconPath;
-  if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName,
-                                                        iconPath))) {
-    Unused << SendSetAudioSessionData(id, sessionName, iconPath);
-  }
-#endif
-
 #ifdef MOZ_CONTENT_SANDBOX
   bool shouldSandbox = true;
   MaybeFileDesc brokerFd = void_t();
   // XXX: Checking the pref here makes it possible to enable/disable sandboxing
   // during an active session. Currently the pref is only used for testing
   // purpose. If the decision is made to permanently rely on the pref, this
   // should be changed so that it is required to restart firefox for the change
   // of value to take effect.
@@ -2418,16 +2407,26 @@ ContentParent::InitInternal(ProcessPrior
       MOZ_ASSERT(static_cast<const FileDescriptor&>(brokerFd).IsValid());
     }
   }
 #endif
   if (shouldSandbox && !SendSetProcessSandbox(brokerFd)) {
     KillHard("SandboxInitFailed");
   }
 #endif
+#if defined(XP_WIN)
+  // Send the info needed to join the browser process's audio session.
+  nsID id;
+  nsString sessionName;
+  nsString iconPath;
+  if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName,
+                                                        iconPath))) {
+    Unused << SendSetAudioSessionData(id, sessionName, iconPath);
+  }
+#endif
 
   {
     RefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get();
     MOZ_ASSERT(swr);
 
     nsTArray<ServiceWorkerRegistrationData> registrations;
     swr->GetRegistrations(registrations);
 
--- a/widget/windows/AudioSession.cpp
+++ b/widget/windows/AudioSession.cpp
@@ -15,17 +15,16 @@
 
 //#include "AudioSession.h"
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/Mutex.h"
 
 #include <objbase.h>
 
 namespace mozilla {
 namespace widget {
 
 /*
  * To take advantage of what Vista+ have to offer with respect to audio,
@@ -50,18 +49,16 @@ public:
                                       DWORD aChangedChannel,
                                       LPCGUID aContext);
   STDMETHODIMP OnDisplayNameChanged(LPCWSTR aDisplayName, LPCGUID aContext);
   STDMETHODIMP OnGroupingParamChanged(LPCGUID aGroupingParam, LPCGUID aContext);
   STDMETHODIMP OnIconPathChanged(LPCWSTR aIconPath, LPCGUID aContext);
   STDMETHODIMP OnSessionDisconnected(AudioSessionDisconnectReason aReason);
 private:
   nsresult OnSessionDisconnectedInternal();
-  nsresult CommitAudioSessionData();
-
 public:
   STDMETHODIMP OnSimpleVolumeChanged(float aVolume,
                                      BOOL aMute,
                                      LPCGUID aContext);
   STDMETHODIMP OnStateChanged(AudioSessionState aState);
 
   nsresult Start();
   nsresult Stop();
@@ -84,18 +81,16 @@ public:
     AUDIO_SESSION_DISCONNECTED // Audio session disconnected
   };
 protected:
   RefPtr<IAudioSessionControl> mAudioSessionControl;
   nsString mDisplayName;
   nsString mIconPath;
   nsID mSessionGroupingParameter;
   SessionState mState;
-  // Guards the IAudioSessionControl
-  mozilla::Mutex mMutex;
 
   ThreadSafeAutoRefCnt mRefCnt;
   NS_DECL_OWNINGTHREAD
 
   static AudioSession* sService;
 };
 
 nsresult
@@ -127,18 +122,17 @@ RecvAudioSessionData(const nsID& aID,
 {
   return AudioSession::GetSingleton()->SetSessionData(aID,
                                                       aSessionName,
                                                       aIconPath);
 }
 
 AudioSession* AudioSession::sService = nullptr;
 
-AudioSession::AudioSession() :
-  mMutex("AudioSessionControl")
+AudioSession::AudioSession()
 {
   mState = UNINITIALIZED;
 }
 
 AudioSession::~AudioSession()
 {
 
 }
@@ -255,47 +249,58 @@ AudioSession::Start()
   hr = device->Activate(IID_IAudioSessionManager,
                         CLSCTX_ALL,
                         nullptr,
                         getter_AddRefs(manager));
   if (FAILED(hr)) {
     return NS_ERROR_FAILURE;
   }
 
-  MutexAutoLock lock(mMutex);
   hr = manager->GetAudioSessionControl(&GUID_NULL,
                                        0,
                                        getter_AddRefs(mAudioSessionControl));
 
   if (FAILED(hr)) {
     return NS_ERROR_FAILURE;
   }
 
+  hr = mAudioSessionControl->SetGroupingParam((LPGUID)&mSessionGroupingParameter,
+                                              nullptr);
+  if (FAILED(hr)) {
+    StopInternal();
+    return NS_ERROR_FAILURE;
+  }
+
+  hr = mAudioSessionControl->SetDisplayName(mDisplayName.get(), nullptr);
+  if (FAILED(hr)) {
+    StopInternal();
+    return NS_ERROR_FAILURE;
+  }
+
+  hr = mAudioSessionControl->SetIconPath(mIconPath.get(), nullptr);
+  if (FAILED(hr)) {
+    StopInternal();
+    return NS_ERROR_FAILURE;
+  }
+
   // Increments refcount of 'this'.
   hr = mAudioSessionControl->RegisterAudioSessionNotification(this);
   if (FAILED(hr)) {
     StopInternal();
     return NS_ERROR_FAILURE;
   }
 
-  nsCOMPtr<nsIRunnable> runnable =
-    NewRunnableMethod("AudioSession::CommitAudioSessionData",
-                      this, &AudioSession::CommitAudioSessionData);
-  NS_DispatchToMainThread(runnable);
-
   mState = STARTED;
 
   return NS_OK;
 }
 
 void
 AudioSession::StopInternal()
 {
-  mMutex.AssertCurrentThreadOwns();
-
   if (mAudioSessionControl &&
       (mState == STARTED || mState == STOPPED)) {
     // Decrement refcount of 'this'
     mAudioSessionControl->UnregisterAudioSessionNotification(this);
   }
   mAudioSessionControl = nullptr;
 }
 
@@ -308,17 +313,16 @@ AudioSession::Stop()
              "State invariants violated");
   SessionState state = mState;
   mState = STOPPED;
 
   {
     RefPtr<AudioSession> kungFuDeathGrip;
     kungFuDeathGrip.swap(sService);
 
-    MutexAutoLock lock(mMutex);
     StopInternal();
   }
 
   if (state != UNINITIALIZED) {
     ::CoUninitialize();
   }
   return NS_OK;
 }
@@ -365,49 +369,16 @@ AudioSession::SetSessionData(const nsID&
   mState = CLONED;
 
   CopynsID(mSessionGroupingParameter, aID);
   mDisplayName = aSessionName;
   mIconPath = aIconPath;
   return NS_OK;
 }
 
-nsresult
-AudioSession::CommitAudioSessionData()
-{
-  MutexAutoLock lock(mMutex);
-
-  if (!mAudioSessionControl) {
-    // Stop() was called before we had a chance to do this.
-    return NS_OK;
-  }
-
-  HRESULT hr =
-    mAudioSessionControl->SetGroupingParam((LPGUID)&mSessionGroupingParameter,
-                                           nullptr);
-  if (FAILED(hr)) {
-    StopInternal();
-    return NS_ERROR_FAILURE;
-  }
-
-  hr = mAudioSessionControl->SetDisplayName(mDisplayName.get(), nullptr);
-  if (FAILED(hr)) {
-    StopInternal();
-    return NS_ERROR_FAILURE;
-  }
-
-  hr = mAudioSessionControl->SetIconPath(mIconPath.get(), nullptr);
-  if (FAILED(hr)) {
-    StopInternal();
-    return NS_ERROR_FAILURE;
-  }
-
-  return NS_OK;
-}
-
 STDMETHODIMP
 AudioSession::OnChannelVolumeChanged(DWORD aChannelCount,
                                      float aChannelVolumeArray[],
                                      DWORD aChangedChannel,
                                      LPCGUID aContext)
 {
   return S_OK; // NOOP
 }
@@ -443,30 +414,25 @@ AudioSession::OnSessionDisconnected(Audi
                       this, &AudioSession::OnSessionDisconnectedInternal);
   NS_DispatchToMainThread(runnable);
   return S_OK;
 }
 
 nsresult
 AudioSession::OnSessionDisconnectedInternal()
 {
-  {
-    // We need to release the mutex before we call Start().
-    MutexAutoLock lock(mMutex);
-
-    if (!mAudioSessionControl)
-      return NS_OK;
+  if (!mAudioSessionControl)
+    return NS_OK;
 
-    // When successful, UnregisterAudioSessionNotification will decrement the
-    // refcount of 'this'.  Start will re-increment it.  In the interim,
-    // we'll need to reference ourselves.
-    RefPtr<AudioSession> kungFuDeathGrip(this);
-    mAudioSessionControl->UnregisterAudioSessionNotification(this);
-    mAudioSessionControl = nullptr;
-  }
+  // When successful, UnregisterAudioSessionNotification will decrement the
+  // refcount of 'this'.  Start will re-increment it.  In the interim,
+  // we'll need to reference ourselves.
+  RefPtr<AudioSession> kungFuDeathGrip(this);
+  mAudioSessionControl->UnregisterAudioSessionNotification(this);
+  mAudioSessionControl = nullptr;
 
   mState = AUDIO_SESSION_DISCONNECTED;
   CoUninitialize();
   Start(); // If it fails there's not much we can do.
   return NS_OK;
 }
 
 STDMETHODIMP