tor-browser

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

commit b77e723fc778eb0b394164a076c5b59befbc04cf
parent 0d1a10fda0ac9aa36277e6955fcb2874b4c7133b
Author: Andrew Osmond <aosmond@mozilla.com>
Date:   Fri,  3 Oct 2025 14:54:03 +0000

Bug 1987906. r=lsalzman

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

Diffstat:
Mgfx/ipc/GPUProcessManager.cpp | 12++++++++++++
Mgfx/ipc/GPUProcessManager.h | 6++++++
Mmodules/libpref/init/StaticPrefList.yaml | 9++++++++-
3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp @@ -209,6 +209,15 @@ void GPUProcessManager::NotifyBatteryInfo( } } +void GPUProcessManager::MaybeCrashIfGpuProcessOnceStable() { + if (StaticPrefs::layers_gpu_process_allow_fallback_to_parent_AtStartup()) { + return; + } + MOZ_RELEASE_ASSERT(!gfxConfig::IsEnabled(Feature::GPU_PROCESS)); + MOZ_RELEASE_ASSERT(!mProcessStableOnce, + "Fallback to parent process not allowed!"); +} + void GPUProcessManager::ResetProcessStable() { mTotalProcessAttempts++; mProcessStable = false; @@ -333,6 +342,8 @@ bool GPUProcessManager::MaybeDisableGPUProcess(const char* aMessage, gfxCriticalNote << aMessage; gfxPlatform::DisableGPUProcess(); + + MaybeCrashIfGpuProcessOnceStable(); } mozilla::glean::gpu_process::feature_status.Set( @@ -936,6 +947,7 @@ void GPUProcessManager::OnProcessUnexpectedShutdown(GPUProcessHost* aHost) { // long enough, reset the counter so that we don't disable the process too // eagerly. if (IsProcessStable(TimeStamp::Now())) { + mProcessStableOnce = true; mUnstableProcessAttempts = 0; } else { mUnstableProcessAttempts++; diff --git a/gfx/ipc/GPUProcessManager.h b/gfx/ipc/GPUProcessManager.h @@ -284,6 +284,11 @@ class GPUProcessManager final : public GPUProcessHost::Listener { bool FallbackFromAcceleration(wr::WebRenderError aError, const nsCString& aMsg); + // Crashes the parent process if we are disabling the GPU process and we + // ever once had a stable GPU process. This is to avoid fallback into the + // parent when we know the configuration allows for the GPU process. + void MaybeCrashIfGpuProcessOnceStable(); + void ResetProcessStable(); // Returns true if the composting pocess is currently considered to be stable. @@ -385,6 +390,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener { GPUProcessHost* mProcess; uint64_t mProcessToken; bool mProcessStable; + bool mProcessStableOnce = false; Maybe<wr::WebRenderError> mLastError; Maybe<nsCString> mLastErrorMsg; GPUChild* mGPUChild; diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml @@ -9523,6 +9523,13 @@ #endif mirror: always +# If true, allow the parent process as a fallback for compositing due to an +# unstable GPU process, otherwise simply crash the parent process. +- name: layers.gpu-process.allow-fallback-to-parent + type: bool + value: false + mirror: once + - name: layers.gpu-process.allow-software type: bool #if defined(XP_WIN) @@ -9602,7 +9609,7 @@ # restarts. - name: layers.gpu-process.stable.min-uptime-ms type: RelaxedAtomicInt32 - value: 4 * 60000 + value: 30000 mirror: always # Note: This pref will only be used if it is less than layers.gpu-process.max_restarts.