diff --git a/xpcom/base/CycleCollectedJSRuntime.h b/xpcom/base/CycleCollectedJSRuntime.h index 7937d935cff..4d306f4a282 100644 --- a/xpcom/base/CycleCollectedJSRuntime.h +++ b/xpcom/base/CycleCollectedJSRuntime.h @@ -215,7 +215,9 @@ private: void TraceNativeGrayRoots(JSTracer* aTracer); void AfterProcessMicrotask(uint32_t aRecursionDepth); +public: void ProcessStableStateQueue(); +private: void ProcessMetastableStateQueue(uint32_t aRecursionDepth); public: diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 82e0b412b31..374e5daaab9 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -4166,6 +4166,11 @@ nsCycleCollector_shutdown() data->mCollector->Shutdown(); data->mCollector = nullptr; + if (data->mRuntime) { + // Run any remaining tasks that may have been enqueued via + // RunInStableState during the final cycle collection. + data->mRuntime->ProcessStableStateQueue(); + } if (!data->mRuntime) { delete data; sCollectorData.set(nullptr);