From 69e561b864c3e248c9b52f6f2578764cdad297c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 27 Jun 2024 11:09:54 +0000 Subject: [PATCH] Bug 1897589 - Simplify worker shutdown checks. r=jstutte,dom-worker-reviewers Differential Revision: https://phabricator.services.mozilla.com/D214740 --- dom/workers/RuntimeService.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 2426a9372401..4251e32e563b 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -2205,19 +2205,15 @@ WorkerThreadPrimaryRunnable::Run() { // Check sentinels if we actually removed all global scope references. // In case use the earlier set-aside raw pointers to not mess with the // ref counting after the cycle collector has gone away. - if (globalScopeSentinel) { - MOZ_ASSERT(!globalScopeSentinel->IsAlive()); - if (NS_WARN_IF(globalScopeSentinel->IsAlive())) { - globalScopeRawPtr->NoteWorkerTerminated(); - globalScopeRawPtr = nullptr; - } + if (NS_WARN_IF(globalScopeSentinel && globalScopeSentinel->IsAlive())) { + MOZ_ASSERT_UNREACHABLE("WorkerGlobalScope alive after worker shutdown"); + globalScopeRawPtr->NoteWorkerTerminated(); + globalScopeRawPtr = nullptr; } - if (debuggerScopeSentinel) { - MOZ_ASSERT(!debuggerScopeSentinel->IsAlive()); - if (NS_WARN_IF(debuggerScopeSentinel->IsAlive())) { - debuggerScopeRawPtr->NoteWorkerTerminated(); - debuggerScopeRawPtr = nullptr; - } + if (NS_WARN_IF(debuggerScopeSentinel && debuggerScopeSentinel->IsAlive())) { + MOZ_ASSERT_UNREACHABLE("Debugger global alive after worker shutdown"); + debuggerScopeRawPtr->NoteWorkerTerminated(); + debuggerScopeRawPtr = nullptr; } }