Backed out 2 changesets (bug 1358372) for mochitest failures on AudioSession, AudioSession::CommitAudioSessionData, Mutex, nsStringBuffer on a CLOSED TREE
authorCosmin Sabou <csabou@mozilla.com>
Wed, 17 Jan 2018 13:56:16 +0200
changeset 453949 871fecd7db1d0847e0b4c48c17eda859f14254f7
parent 453948 3b3d07447b8203e7370a51972d34064d701fb44e
child 453950 f4d2bd7f41da8e6ddfb5e2a5664893b0288645a7
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)
bugs1358372
milestone59.0a1
backs out76e48321127db6d2cee3ac0ff094a806256d1868
f8b2bbebb2f0ee6c8faa3c0023d2ceaa6796e02e
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 2 changesets (bug 1358372) for mochitest failures on AudioSession, AudioSession::CommitAudioSessionData, Mutex, nsStringBuffer on a CLOSED TREE Backed out changeset 76e48321127d (bug 1358372) Backed out changeset f8b2bbebb2f0 (bug 1358372)
dom/ipc/ContentParent.cpp
widget/windows/AudioSession.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2377,27 +2377,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.
@@ -2419,16 +2408,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,44 +369,16 @@ AudioSession::SetSessionData(const nsID&
   mState = CLONED;
 
   CopynsID(mSessionGroupingParameter, aID);
   mDisplayName = aSessionName;
   mIconPath = aIconPath;
   return NS_OK;
 }
 
-nsresult
-AudioSession::CommitAudioSessionData()
-{
-  MutexAutoLock lock(mMutex);
-
-  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
 }
@@ -438,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