Bug 1642849 shut down MediaTrackGraph from AudioContext when window will be destroyed r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D74814
This commit is contained in:
Karl Tomlinson 2020-06-12 03:53:34 +00:00
Родитель 7e87e93b6b
Коммит 209a34c2b7
4 изменённых файлов: 17 добавлений и 11 удалений

Просмотреть файл

@ -1137,7 +1137,7 @@ void nsGlobalWindowInner::FreeInnerObjects() {
NotifyWindowIDDestroyed("inner-window-destroyed");
for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
mAudioContexts[i]->Shutdown();
mAudioContexts[i]->OnWindowDestroy();
}
mAudioContexts.Clear();

Просмотреть файл

@ -743,11 +743,11 @@ nsISerialEventTarget* AudioContext::GetMainThread() const {
void AudioContext::DisconnectFromOwner() {
mIsDisconnecting = true;
Shutdown();
OnWindowDestroy();
DOMEventTargetHelper::DisconnectFromOwner();
}
void AudioContext::Shutdown() {
void AudioContext::OnWindowDestroy() {
// Avoid resend the Telemetry data.
if (!mIsShutDown) {
MaybeUpdateAutoplayTelemetryWhenShutdown();
@ -776,11 +776,20 @@ void AudioContext::Shutdown() {
// PBrowser::Destroy() message before xpcom shutdown begins.
ShutdownWorklet();
// For offline contexts, we can destroy the MediaTrackGraph at this point.
if (mIsOffline && mDestination) {
if (mDestination) {
// We can destroy the MediaTrackGraph at this point.
// Although there may be other clients using the graph, this graph is used
// only for clients in the same window and this window is going away.
// This will also interrupt any worklet script still running on the graph
// thread.
Graph()->ForceShutDown();
// AudioDestinationNodes on rendering offline contexts have a
// self-reference which needs removal.
if (mIsOffline) {
mDestination->OfflineShutdown();
}
}
}
/* This runnable allows to fire the "statechange" event */
class OnStateChangeTask final : public Runnable {

Просмотреть файл

@ -151,7 +151,7 @@ class AudioContext final : public DOMEventTargetHelper,
virtual void DisconnectFromOwner() override;
void Shutdown(); // idempotent
void OnWindowDestroy(); // idempotent
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;

Просмотреть файл

@ -488,11 +488,8 @@ void AudioDestinationNode::OfflineShutdown() {
MOZ_ASSERT(Context() && Context()->IsOffline(),
"Should only be called on a valid OfflineAudioContext");
if (mTrack) {
mTrack->Graph()->MediaTrackGraph::ForceShutDown();
mOfflineRenderingRef.Drop(this);
}
}
JSObject* AudioDestinationNode::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {