tor-browser

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

commit 3e1ae93e85fa3e58e28af405c59488063db8abe7
parent 6cee40cca80c67e1887dce5578ddb6b1179e6d17
Author: Brad Werth <werth@efn.org>
Date:   Mon, 10 Nov 2025 20:40:34 +0000

Bug 1852794 Part 1: Add a gfx feature to control mesa threading. r=aosmond

This adds a gfxPlatformGtk::InitMesaThreading() function to check the
gfxInfo blocklist, and then disable using an environment variable. The
existing setenv in gfxPlatformGtk::InitX11EGLConfig() is moved into the
newly-defined function.

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

Diffstat:
Mgfx/config/gfxFeature.h | 1+
Mgfx/thebes/gfxPlatformGtk.cpp | 37++++++++++++++++++++++++++++++++-----
Mgfx/thebes/gfxPlatformGtk.h | 1+
Mwidget/GfxInfoFeatureDefs.h | 2++
4 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/gfx/config/gfxFeature.h b/gfx/config/gfxFeature.h @@ -62,6 +62,7 @@ namespace gfx { _(WMF_HW_DRM, Feature, "Windows Media Foundation hardware DRM") \ _(GL_NORM16_TEXTURES, Feature, "OpenGL normalized 16-bit texture formats") \ _(WEBGPU_EXTERNAL_TEXTURE, Feature, "WebGPU external textures") \ + _(MESA_THREADING, Feature, "Mesa glthread enabled") \ /* Add new entries above this comment */ enum class Feature : uint32_t { diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp @@ -124,6 +124,8 @@ gfxPlatformGtk::gfxPlatformGtk() { // Bug 1714483: Force disable FXAA Antialiasing on NV drivers. This is a // temporary workaround for a driver bug. PR_SetEnv("__GL_ALLOW_FXAA_USAGE=0"); + + InitMesaThreading(); } gfxPlatformGtk::~gfxPlatformGtk() { @@ -173,11 +175,6 @@ void gfxPlatformGtk::InitX11EGLConfig() { feature.ForceDisable(FeatureStatus::Broken, "glxtest could not use EGL", "FEATURE_FAILURE_GLXTEST_NO_EGL"_ns); } - - if (feature.IsEnabled() && IsX11Display()) { - // Enabling glthread crashes on X11/EGL, see bug 1670545 - PR_SetEnv("mesa_glthread=false"); - } #else feature.DisableByDefault(FeatureStatus::Unavailable, "X11 support missing", "FEATURE_FAILURE_NO_X11"_ns); @@ -330,6 +327,36 @@ void gfxPlatformGtk::InitPlatformGPUProcessPrefs() { #endif } +void gfxPlatformGtk::InitMesaThreading() { + FeatureState& featureMesaThreading = + gfxConfig::GetFeature(Feature::MESA_THREADING); + featureMesaThreading.EnableByDefault(); + + nsCString failureId; + int32_t status; + nsCOMPtr<nsIGfxInfo> gfxInfo = components::GfxInfo::Service(); + if (NS_FAILED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_MESA_THREADING, + failureId, &status))) { + featureMesaThreading.Disable(FeatureStatus::BlockedNoGfxInfo, + "gfxInfo is broken", + "FEATURE_FAILURE_NO_GFX_INFO"_ns); + } else if (status != nsIGfxInfo::FEATURE_STATUS_OK) { + featureMesaThreading.Disable(FeatureStatus::Blocklisted, + "Blocklisted by gfxInfo", failureId); + } + + // Enabling glthread crashes on X11/EGL, see bug 1670545 + if (gfxConfig::IsEnabled(Feature::X11_EGL) && IsX11Display()) { + featureMesaThreading.Disable(FeatureStatus::Failed, + "No glthread with EGL and X11", + "FEATURE_FAILURE_EGL_X11"_ns); + } + + if (!featureMesaThreading.IsEnabled()) { + PR_SetEnv("mesa_glthread=false"); + } +} + already_AddRefed<gfxASurface> gfxPlatformGtk::CreateOffscreenSurface( const IntSize& aSize, gfxImageFormat aFormat) { if (!Factory::AllowedSurfaceSize(aSize)) { diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h @@ -68,6 +68,7 @@ class gfxPlatformGtk final : public gfxPlatform { void InitPlatformHardwareVideoConfig() override; void InitPlatformGPUProcessPrefs() override; void InitWebRenderConfig() override; + void InitMesaThreading(); void BuildContentDeviceData(mozilla::gfx::ContentDeviceData* aOut) override; private: diff --git a/widget/GfxInfoFeatureDefs.h b/widget/GfxInfoFeatureDefs.h @@ -133,3 +133,5 @@ GFXINFO_FEATURE(GL_NORM16_TEXTURES, "GL_NORM16", "gl.norm16-textures") GFXINFO_FEATURE(HARDWARE_VIDEO_ENCODING, "HARDWARE_VIDEO_ENCODING", "hardwarevideoencoding") /* Whether WebGPU's GPUExternalTexture API is supported, starting in 143. */ GFXINFO_FEATURE(WEBGPU_EXTERNAL_TEXTURE, "WEBGPU_EXTERNAL_TEXTURE", "webgpu.external-texture") +/* Whether Mesa threading is allowed, starting in 146. */ +GFXINFO_FEATURE(MESA_THREADING, "MESA_THREADING", "mesa.threading")