tor-browser

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

commit 670d3ef0ae84d0a4faf0913a50915bde48c75773
parent b7470bd8cb29eca64ece87ddd14d730c8071c79f
Author: Andrew Osmond <aosmond@gmail.com>
Date:   Tue, 14 Oct 2025 17:42:49 +0000

Bug 1994188 - Remove duplicate calls to GPUProcessManager::EnsureGPUReady on nsBaseWidget::CreateCompositor paths. r=gfx-reviewers,lsalzman

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

Diffstat:
Mgfx/ipc/GPUProcessManager.cpp | 51++++++++++-----------------------------------------
Mgfx/ipc/GPUProcessManager.h | 5+----
Mwidget/cocoa/nsCocoaWindow.mm | 9++-------
Mwidget/nsIWidget.cpp | 3+--
4 files changed, 14 insertions(+), 54 deletions(-)

diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp @@ -352,9 +352,12 @@ bool GPUProcessManager::MaybeDisableGPUProcess(const char* aMessage, // process equivalent, and we need to make sure those services are setup // correctly. We cannot re-enter DisableGPUProcess from this call because we // know that it is disabled in the config above. - DebugOnly<bool> ready = EnsureProtocolsReady(); - MOZ_ASSERT_IF(!ready, - AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdown)); + if (NS_WARN_IF(NS_FAILED(EnsureGPUReady()))) { + MOZ_ASSERT(AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdown)); + } else { + DebugOnly<bool> ready = EnsureProtocolsReady(); + MOZ_ASSERT(ready); + } // If we disable the GPU process during reinitialization after a previous // crash, then we need to tell the content processes again, because they @@ -379,8 +382,7 @@ bool GPUProcessManager::IsGPUReady() const { return false; } -nsresult GPUProcessManager::EnsureGPUReady( - bool aRetryAfterFallback /* = true */) { +nsresult GPUProcessManager::EnsureGPUReady() { MOZ_ASSERT(NS_IsMainThread()); // We only wait to fail with NS_ERROR_ILLEGAL_DURING_SHUTDOWN if we would @@ -413,13 +415,6 @@ nsresult GPUProcessManager::EnsureGPUReady( // or it will have disabled the GPU process. MOZ_ASSERT(!mProcess); MOZ_ASSERT(!mGPUChild); - - // If aRetryAfterFallback is true, we will relaunch the process - // immediately in this loop (if still enabled). Otherwise we return to - // the caller to allow them to reconfigure first. - if (!aRetryAfterFallback) { - return NS_ERROR_ABORT; - } continue; } } @@ -442,13 +437,6 @@ nsresult GPUProcessManager::EnsureGPUReady( // reasons, before first falling back from acceleration, and eventually // disabling the GPU process altogether. OnProcessUnexpectedShutdown(mProcess); - - // If aRetryAfterFallback is true, we will relaunch the process immediately - // in this loop (if still enabled). Otherwise we return to the caller to - // allow them to reconfigure first. - if (!aRetryAfterFallback) { - return NS_ERROR_ABORT; - } } MOZ_DIAGNOSTIC_ASSERT(!gfxConfig::IsEnabled(Feature::GPU_PROCESS)); @@ -464,10 +452,6 @@ nsresult GPUProcessManager::EnsureGPUReady( } bool GPUProcessManager::EnsureProtocolsReady() { - if (NS_WARN_IF(NS_FAILED(EnsureGPUReady()))) { - return false; - } - return EnsureCompositorManagerChild() && EnsureImageBridgeChild() && EnsureVRManager(); } @@ -1225,31 +1209,16 @@ already_AddRefed<CompositorSession> GPUProcessManager::CreateTopLevelCompositor( CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize, uint64_t aInnerWindowId, bool* aRetryOut) { + MOZ_ASSERT(IsGPUReady()); MOZ_ASSERT(aRetryOut); - LayersId layerTreeId = AllocateLayerTreeId(); - - RefPtr<CompositorSession> session; - - nsresult rv = EnsureGPUReady(/* aRetryAfterFallback */ false); - - // If we used fallback, then retry creating the compositor sessions because - // our configuration may have changed. - if (rv == NS_ERROR_ABORT) { - *aRetryOut = true; - return nullptr; - } - - if (NS_WARN_IF(NS_FAILED(rv))) { - *aRetryOut = false; - return nullptr; - } - if (!EnsureProtocolsReady()) { *aRetryOut = false; return nullptr; } + LayersId layerTreeId = AllocateLayerTreeId(); + RefPtr<CompositorSession> session; if (mGPUChild) { session = CreateRemoteSession(aWidget, aLayerManager, layerTreeId, aScale, aOptions, aUseExternalSurfaceSize, diff --git a/gfx/ipc/GPUProcessManager.h b/gfx/ipc/GPUProcessManager.h @@ -103,10 +103,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener { // process, even if in shutdown. // - NS_ERROR_ILLEGAL_DURING_SHUTDOWN if compositing is not ready, and we are // in shutdown. - // - NS_ERROR_ABORT if compositing is not ready, we failed to make it ready - // under the previous configuration, and that the configuration may have - // changed. This is only returned when aRetryAfterFallback is false. - nsresult EnsureGPUReady(bool aRetryAfterFallback = true); + nsresult EnsureGPUReady(); already_AddRefed<CompositorSession> CreateTopLevelCompositor( nsIWidget* aWidget, WebRenderLayerManager* aLayerManager, diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm @@ -894,14 +894,9 @@ void nsCocoaWindow::CreateCompositor(int aWidth, int aHeight) { // Make sure the gfxPlatform is initialized, which is necessary to create // the GPUProcessManager. Unused << gfxPlatform::GetPlatform(); - auto* pm = mozilla::gfx::GPUProcessManager::Get(); MOZ_ASSERT( - pm, "Getting the gfxPlatform should have created the GPUProcessManager."); - - // Ensure the GPU process has had a chance to start. The logic in - // GetCompositorWidgetInitData will handle both success and error cases - // correctly, so we don't check an error code. - pm->EnsureGPUReady(); + mozilla::gfx::GPUProcessManager::Get(), + "Getting the gfxPlatform should have created the GPUProcessManager."); // Do the rest of the compositor setup. nsIWidget::CreateCompositor(aWidth, aHeight); diff --git a/widget/nsIWidget.cpp b/widget/nsIWidget.cpp @@ -1567,8 +1567,7 @@ already_AddRefed<WebRenderLayerManager> nsIWidget::CreateCompositorSession( retry = true; DestroyCompositor(); // gfxVars::UseDoubleBufferingWithCompositor() is also disabled. - gfx::GPUProcessManager::Get()->DisableWebRender( - wr::WebRenderError::INITIALIZE, error); + gpm->DisableWebRender(wr::WebRenderError::INITIALIZE, error); } }