tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit b8e5f0230d0cfd61586ba09d6a658c2eca992e17
parent c932fd8c5f7aedb4dcf3d7748289fce49e83601f
Author: Jamie Nicol <jnicol@mozilla.com>
Date:   Tue, 18 Nov 2025 08:34:16 +0000

Bug 1993818 - Don't add battery observer after xpcom-will-shutdown. r=bradwerth

In bug 1981068 we made GPUProcessManager remove its battery observer
in xpcom-will-shutdown rather than xpcom-shutdown, to ensure there are
no outstanding observers when MacPowerInformationService shuts down in
response to xpcom-shutdown. However, if the GPU process launch
completes after xpcom-will-shutdown but before xpcom-shutdown, then we
will create a new battery observer, causing the assertion that there
are no outstanding observers during xpcom-shutdown to fail.

This patch avoids this by checking the shutdown phase prior to
creating the observer. Temporarily running without the observer is
harmless, and the GPU process will be shutdown imminently anyway.

Differential Revision: https://phabricator.services.mozilla.com/D272843

Diffstat:
Mgfx/ipc/GPUProcessManager.cpp | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp @@ -634,7 +634,9 @@ void GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) { mGPUChild->SendInitVsyncBridge(std::move(vsyncParent)); MOZ_DIAGNOSTIC_ASSERT(!mBatteryObserver); - mBatteryObserver = new BatteryObserver(); + if (!AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMWillShutdown)) { + mBatteryObserver = new BatteryObserver(); + } // Flush any pref updates that happened during launch and weren't // included in the blobs set up in LaunchGPUProcess.