tor-browser

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

commit fb70d4fe0ecd428400f1702e54b68b0dbcf1947c
parent 5edb65b5ea488a52b767ada1591fe02562b9e330
Author: Andrew Osmond <aosmond@mozilla.com>
Date:   Thu,  2 Oct 2025 19:59:28 +0000

Bug 1991502 - Ensure we retry launching the GPU process after early launch errors. r=gfx-reviewers,bradwerth

This patch makes us restart the GPU process after it fails to
launch during the initial setup. This is prior to any IPDL actors
are setup, so there is not much interesting done yet from a
graphics perspective. As such we treat this as an unstable process
and follow the same fallback algorithm.

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

Diffstat:
Mgfx/ipc/GPUProcessManager.cpp | 24++++++++++++++++++++----
Mgfx/ipc/GPUProcessManager.h | 1+
Mmodules/libpref/init/StaticPrefList.yaml | 11+++++++++++
3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp @@ -392,9 +392,11 @@ nsresult GPUProcessManager::EnsureGPUReady( if (!mProcess->WaitForLaunch()) { // If this fails, we should have fired OnProcessLaunchComplete and - // removed the process. - MOZ_ASSERT(!mProcess && !mGPUChild); - return NS_ERROR_FAILURE; + // removed the process. The algorithm either allows us another attempt + // or it will have disabled the GPU process. + MOZ_ASSERT(!mProcess); + MOZ_ASSERT(!mGPUChild); + continue; } } @@ -574,11 +576,25 @@ GPUProcessManager::CreateUiCompositorController(nsBaseWidget* aWidget, void GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) { MOZ_ASSERT(mProcess && mProcess == aHost); + // By definition, the process failing to launch is an unstable attempt. While + // we did not get to the point where we are using the features, we should just + // follow the same fallback procedure. if (!mProcess->IsConnected()) { - DisableGPUProcess("Failed to connect GPU process"); + ++mLaunchProcessAttempts; + if (mLaunchProcessAttempts > + uint32_t(StaticPrefs::layers_gpu_process_max_launch_attempts())) { + char disableMessage[64]; + SprintfLiteral(disableMessage, + "Failed to launch GPU process after %d attempts", + mLaunchProcessAttempts); + DisableGPUProcess(disableMessage); + } else { + DestroyProcess(/* aUnexpectedShutdown */ true); + } return; } + mLaunchProcessAttempts = 0; mGPUChild = mProcess->GetActor(); mProcessToken = mProcess->GetProcessToken(); #if defined(XP_WIN) diff --git a/gfx/ipc/GPUProcessManager.h b/gfx/ipc/GPUProcessManager.h @@ -368,6 +368,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener { uint32_t mUnstableProcessAttempts; uint32_t mTotalProcessAttempts; + uint32_t mLaunchProcessAttempts = 0; TimeStamp mProcessAttemptLastTime; nsTArray<RefPtr<RemoteCompositorSession>> mRemoteSessions; diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml @@ -9569,6 +9569,17 @@ value: 20000 mirror: once +# How many additional attempts to launch the GPU process we try if we fail +# during process launch, before any configuration is attempted. +- name: layers.gpu-process.max_launch_attempts + type: RelaxedAtomicInt32 +#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) + value: 2 +#else + value: 0 +#endif + mirror: always + # How many unstable GPU process restarts we allow for a given configuration. - name: layers.gpu-process.max_restarts type: RelaxedAtomicInt32