commit a7b1b356be396377b98cf8511a15ab2a82af6823
parent a662298aa9fba344c2fd19624ed3e500e3bf853a
Author: Andrew Osmond <aosmond@mozilla.com>
Date: Tue, 30 Sep 2025 15:40:22 +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:
1 file changed, 23 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,8 +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");
+ ++mUnstableProcessAttempts;
+ mozilla::glean::gpu_process::unstable_launch_attempts.Set(
+ mUnstableProcessAttempts);
+ if (mUnstableProcessAttempts >
+ uint32_t(StaticPrefs::layers_gpu_process_max_restarts())) {
+ char disableMessage[64];
+ SprintfLiteral(disableMessage,
+ "Failed to connect GPU process after %d attempts",
+ mTotalProcessAttempts);
+ if (!MaybeDisableGPUProcess(disableMessage, /* aAllowRestart */ true)) {
+ // Fallback wants the GPU process. Reset our counter.
+ MOZ_DIAGNOSTIC_ASSERT(gfxConfig::IsEnabled(Feature::GPU_PROCESS));
+ mUnstableProcessAttempts = 0;
+ }
+ }
return;
}