tor-browser

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

commit 1becf778fc86b54766c711ccb5f00aeaf796a378
parent bd090dc2ac242d150be1f36bfeb80140d409a098
Author: Andrew Osmond <aosmond@gmail.com>
Date:   Thu,  9 Oct 2025 23:51:49 +0000

Bug 1993594 - Ensure when Firefox is backgrounded on Android that the GPU process is not recorded as stable. r=gfx-reviewers,lsalzman

While we want to treat backgrounding as a situation where we expect the
GPU process to crash, we don't want to record it as having been once
stable for the purposes of crashing the parent process. Otherwise that
will cause users who background Firefox immediately after launch to
supposedly have had a stable GPU process, and crash the parent if we
want to fallback to the parent process for compositing.

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

Diffstat:
Mgfx/ipc/GPUProcessManager.cpp | 20++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp @@ -225,17 +225,6 @@ void GPUProcessManager::ResetProcessStable() { } bool GPUProcessManager::IsProcessStable(const TimeStamp& aNow) { -#ifdef MOZ_WIDGET_ANDROID - // On Android if the process is lost whilst in the background it was probably - // killed by the OS, and it may never have had a chance to have been declared - // stable prior to being killed. We don't want this happening repeatedly to - // result in the GPU process being disabled, so treat any process lost whilst - // in the background as stable. - if (!mAppInForeground) { - return true; - } -#endif - if (mTotalProcessAttempts > 0) { auto delta = (int32_t)(aNow - mProcessAttemptLastTime).ToMilliseconds(); if (delta < StaticPrefs::layers_gpu_process_stable_min_uptime_ms()) { @@ -739,7 +728,7 @@ bool GPUProcessManager::DisableWebRenderConfig(wr::WebRenderError aError, // bad driver state. In that case, we should consider restarting the GPU // process, or simulating a device reset to teardown the compositors to // hopefully alleviate the situation. - if (IsProcessStable(TimeStamp::Now())) { + if (IsProcessStable(TimeStamp::Now()) || (kIsAndroid && !mAppInForeground)) { if (mProcess) { mProcess->KillProcess(/* aGenerateMinidump */ false); } else { @@ -949,6 +938,13 @@ void GPUProcessManager::OnProcessUnexpectedShutdown(GPUProcessHost* aHost) { if (IsProcessStable(TimeStamp::Now())) { mProcessStableOnce = true; mUnstableProcessAttempts = 0; + } else if (kIsAndroid && !mAppInForeground) { + // On Android if the process is lost whilst in the background it was + // probably killed by the OS, and it may never have had a chance to have + // been declared stable prior to being killed. We don't want this happening + // repeatedly to result in the GPU process being disabled, so treat any + // process lost whilst in the background as stable. + mUnstableProcessAttempts = 0; } else { mUnstableProcessAttempts++; mozilla::glean::gpu_process::unstable_launch_attempts.Set(