diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 9e2bceee0044..f43979426475 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -2813,6 +2813,18 @@ ShutdownObserver::Observe(nsISupports* aSubject, MOZ_ASSERT(!strcmp(aTopic, PROFILE_BEFORE_CHANGE_QM_OBSERVER_ID)); MOZ_ASSERT(gInstance); + nsCOMPtr observerService = + mozilla::services::GetObserverService(); + if (NS_WARN_IF(!observerService)) { + return NS_ERROR_FAILURE; + } + + // Unregister ourselves from the observer service first to make sure the + // nested event loop below will not cause re-entrancy issues. + Unused << + observerService->RemoveObserver(this, + PROFILE_BEFORE_CHANGE_QM_OBSERVER_ID); + QuotaManagerService* qms = QuotaManagerService::Get(); MOZ_ASSERT(qms);