mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1540913 - Part 2: Clear and shutdown ModuleLoader at worker termination; r=asuth,jonco
When running an infinitely-looping dynamic import, it is possible for the module loader to still be holding on to that module at shutdown. Shutdown on the worker means that we will no longer run the event loop, which will execute the dynamic import promises necessary to clear the global. The result is that the global is kept alive. By calling `Shutdown()` we prevent this partially. We additionally need to address the failure in the module code (next patch). Differential Revision: https://phabricator.services.mozilla.com/D171683
This commit is contained in:
parent
4e6402f008
commit
5231b910c8
@ -2046,6 +2046,8 @@ WorkerThreadPrimaryRunnable::Run() {
|
||||
MOZ_ASSERT(!JS_IsExceptionPending(cx));
|
||||
}
|
||||
|
||||
mWorkerPrivate->ShutdownModuleLoader();
|
||||
|
||||
mWorkerPrivate->RunShutdownTasks();
|
||||
|
||||
BackgroundChild::CloseForCurrentThread();
|
||||
|
@ -3899,6 +3899,23 @@ WorkerPrivate::ProcessAllControlRunnablesLocked() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void WorkerPrivate::ShutdownModuleLoader() {
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
WorkerGlobalScope* globalScope = GlobalScope();
|
||||
if (globalScope) {
|
||||
if (globalScope->GetModuleLoader(nullptr)) {
|
||||
globalScope->GetModuleLoader(nullptr)->Shutdown();
|
||||
}
|
||||
}
|
||||
WorkerDebuggerGlobalScope* debugGlobalScope = DebuggerGlobalScope();
|
||||
if (debugGlobalScope) {
|
||||
if (debugGlobalScope->GetModuleLoader(nullptr)) {
|
||||
debugGlobalScope->GetModuleLoader(nullptr)->Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorkerPrivate::ClearMainEventQueue(WorkerRanOrNot aRanOrNot) {
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
|
@ -456,6 +456,8 @@ class WorkerPrivate final
|
||||
return mCancelAllPendingRunnables;
|
||||
}
|
||||
|
||||
void ShutdownModuleLoader();
|
||||
|
||||
void ClearMainEventQueue(WorkerRanOrNot aRanOrNot);
|
||||
|
||||
void ClearDebuggerEventQueue();
|
||||
|
@ -993,6 +993,7 @@ ModuleLoaderBase::~ModuleLoaderBase() {
|
||||
}
|
||||
|
||||
void ModuleLoaderBase::Shutdown() {
|
||||
CancelAndClearDynamicImports();
|
||||
MOZ_ASSERT(mFetchingModules.IsEmpty());
|
||||
|
||||
for (const auto& entry : mFetchedModules) {
|
||||
|
Loading…
Reference in New Issue
Block a user