Commit f531d372 authored by Karl Tomlinson's avatar Karl Tomlinson
Browse files

bug 1255618 remove AudioContext from global window at unlink r=Ehsan

mDestination is cleared during unlink, which means that after that point the
window can't do much with the AudioContext, nor should need to do so.

MozReview-Commit-ID: E45aCpEfJEu

--HG--
extra : rebase_source : cafd502552b7126bcdddc2544c4c28c1b62a701f
parent 6845def2
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -60,6 +60,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AudioContext)
  if (!tmp->mIsStarted) {
    NS_IMPL_CYCLE_COLLECTION_UNLINK(mActiveNodes)
  }
  // Remove weak reference on the global window as the context is not usable
  // without mDestination.
  tmp->DisconnectFromWindow();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(DOMEventTargetHelper)

NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(AudioContext,
@@ -137,13 +140,18 @@ AudioContext::Init()
  return NS_OK;
}

AudioContext::~AudioContext()
void
AudioContext::DisconnectFromWindow()
{
  nsPIDOMWindowInner* window = GetOwner();
  if (window) {
    window->RemoveAudioContext(this);
  }
}

AudioContext::~AudioContext()
{
  DisconnectFromWindow();
  UnregisterWeakMemoryReporter(this);
}

+1 −0
Original line number Diff line number Diff line
@@ -311,6 +311,7 @@ public:
  IMPL_EVENT_HANDLER(mozinterruptend)

private:
  void DisconnectFromWindow();
  void RemoveFromDecodeQueue(WebAudioDecodeJob* aDecodeJob);
  void ShutdownDecoder();