From b425b13fa9717ae146faece5fe0bbe85577f0f02 Mon Sep 17 00:00:00 2001 From: Matthew John Cheetham Date: Mon, 23 Oct 2023 12:16:12 -0700 Subject: [PATCH] settings: default SW rendering on Windows+ARM Default to software GUI rendering on Windows on ARM. Users can explicitly set the config to re-enable HW accelerated rendering if they wish. --- docs/configuration.md | 4 ++++ docs/environment.md | 4 ++++ src/shared/Core/PlatformUtils.cs | 16 ++++++++++++++++ src/shared/Core/Settings.cs | 7 ++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index ac0658b466..e82fd04d39 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -247,6 +247,10 @@ git config --global credential.guiSoftwareRendering true Defaults to false (use hardware acceleration where available). +> [!NOTE] +> On ARM64 Windows the default is true (use software rendering) to workaround a +> known Avalonia issue: + **Also see: [GCM_GUI_SOFTWARE_RENDERING][gcm-gui-software-rendering]** --- diff --git a/docs/environment.md b/docs/environment.md index 3612c1d0fa..e915075fec 100644 --- a/docs/environment.md +++ b/docs/environment.md @@ -294,6 +294,10 @@ export GCM_GUI_SOFTWARE_RENDERING=1 Defaults to false (use hardware acceleration where available). +> [!NOTE] +> On ARM64 Windows the default is true (use software rendering) to workaround a +> known Avalonia issue: + **Also see: [credential.guiSoftwareRendering][credential-guisoftwarerendering]** --- diff --git a/src/shared/Core/PlatformUtils.cs b/src/shared/Core/PlatformUtils.cs index 212c132194..ed0e2ec7d5 100644 --- a/src/shared/Core/PlatformUtils.cs +++ b/src/shared/Core/PlatformUtils.cs @@ -53,6 +53,22 @@ public static bool IsDevBox() #endif } + /// + /// Returns true if the current process is running on an ARM processor. + /// + /// True if ARM(v6,hf) or ARM64, false otherwise + public static bool IsArm() + { + switch (RuntimeInformation.OSArchitecture) + { + case Architecture.Arm: + case Architecture.Arm64: + return true; + default: + return false; + } + } + public static bool IsWindowsBrokerSupported() { if (!IsWindows()) diff --git a/src/shared/Core/Settings.cs b/src/shared/Core/Settings.cs index ac92b23f8e..4889b54421 100644 --- a/src/shared/Core/Settings.cs +++ b/src/shared/Core/Settings.cs @@ -568,10 +568,15 @@ public bool UseSoftwareRendering { get { + // WORKAROUND: Some Windows ARM devices have a graphics driver issue that causes transparent windows + // when using hardware rendering. Until this is fixed, we will default to software rendering on these + // devices. Users can always override this setting back to HW-accelerated rendering if they wish. + bool defaultValue = PlatformUtils.IsWindows() && PlatformUtils.IsArm(); + return TryGetSetting(KnownEnvars.GcmGuiSoftwareRendering, KnownGitCfg.Credential.SectionName, KnownGitCfg.Credential.GuiSoftwareRendering, - out string str) && str.ToBooleanyOrDefault(false); + out string str) && str.ToBooleanyOrDefault(defaultValue); } }