зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1634200 don't create a new global when the Worklet is finished r=padenot
When the worklet has already received the notification to shut down, there will be no further notfication to release another global. Differential Revision: https://phabricator.services.mozilla.com/D85975
This commit is contained in:
Родитель
7ab9a436b9
Коммит
5195905845
|
@ -247,7 +247,12 @@ void WorkletNodeEngine::ConstructProcessor(
|
|||
UniqueMessagePortId& aPortIdentifier, AudioNodeTrack* aTrack) {
|
||||
MOZ_ASSERT(mInputs.mPorts.empty() && mOutputs.mPorts.empty());
|
||||
RefPtr<AudioWorkletGlobalScope> global = aWorkletImpl->GetGlobalScope();
|
||||
MOZ_ASSERT(global); // global has already been used to register processor
|
||||
if (!global) {
|
||||
// A global was previously used to register this kind of processor. If it
|
||||
// no longer exists now, that is because the document is going away and so
|
||||
// there is no need to send an error.
|
||||
return;
|
||||
}
|
||||
AutoJSAPI api;
|
||||
if (NS_WARN_IF(!api.Init(global))) {
|
||||
SendProcessorError(aTrack, nullptr);
|
||||
|
|
|
@ -38,7 +38,8 @@ WorkletLoadInfo::WorkletLoadInfo(nsPIDOMWindowInner* aWindow)
|
|||
WorkletImpl::WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal)
|
||||
: mPrincipal(NullPrincipal::CreateWithInheritedAttributes(aPrincipal)),
|
||||
mWorkletLoadInfo(aWindow),
|
||||
mTerminated(false) {
|
||||
mTerminated(false),
|
||||
mFinishedOnExecutionThread(false) {
|
||||
Unused << NS_WARN_IF(
|
||||
NS_FAILED(ipc::PrincipalToPrincipalInfo(mPrincipal, &mPrincipalInfo)));
|
||||
|
||||
|
@ -67,6 +68,9 @@ dom::WorkletGlobalScope* WorkletImpl::GetGlobalScope() {
|
|||
if (mGlobalScope) {
|
||||
return mGlobalScope;
|
||||
}
|
||||
if (mFinishedOnExecutionThread) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dom::AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
|
@ -97,9 +101,12 @@ void WorkletImpl::NotifyWorkletFinished() {
|
|||
}
|
||||
|
||||
// Release global scope on its thread.
|
||||
SendControlMessage(NS_NewRunnableFunction(
|
||||
"WorkletImpl::NotifyWorkletFinished",
|
||||
[self = RefPtr<WorkletImpl>(this)]() { self->mGlobalScope = nullptr; }));
|
||||
SendControlMessage(
|
||||
NS_NewRunnableFunction("WorkletImpl::NotifyWorkletFinished",
|
||||
[self = RefPtr<WorkletImpl>(this)]() {
|
||||
self->mFinishedOnExecutionThread = true;
|
||||
self->mGlobalScope = nullptr;
|
||||
}));
|
||||
|
||||
mTerminated = true;
|
||||
if (mWorkletThread) {
|
||||
|
|
|
@ -100,6 +100,7 @@ class WorkletImpl {
|
|||
|
||||
// Execution thread only.
|
||||
RefPtr<dom::WorkletGlobalScope> mGlobalScope;
|
||||
bool mFinishedOnExecutionThread;
|
||||
|
||||
Maybe<nsID> mAgentClusterId;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче