From c59447c407c8bc705df3f7a0e0270727909324a2 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 15 Jul 2025 10:24:14 +0900 Subject: [PATCH 1/5] Re-enable debug settings --- .../Overlays/FirstRunSetup/ScreenBehaviour.cs | 9 +- .../Settings/Sections/DebugSection.cs | 13 +- .../Sections/DebugSettings/GeneralSettings.cs | 21 +-- .../Sections/DebugSettings/MemorySettings.cs | 123 +++++++++--------- osu.Game/Overlays/SettingsOverlay.cs | 9 +- 5 files changed, 86 insertions(+), 89 deletions(-) diff --git a/osu.Game/Overlays/FirstRunSetup/ScreenBehaviour.cs b/osu.Game/Overlays/FirstRunSetup/ScreenBehaviour.cs index a583ba5f6b..00a753f481 100644 --- a/osu.Game/Overlays/FirstRunSetup/ScreenBehaviour.cs +++ b/osu.Game/Overlays/FirstRunSetup/ScreenBehaviour.cs @@ -1,11 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Localisation; @@ -22,7 +19,7 @@ namespace osu.Game.Overlays.FirstRunSetup [LocalisableDescription(typeof(FirstRunSetupOverlayStrings), nameof(FirstRunSetupOverlayStrings.Behaviour))] public partial class ScreenBehaviour : WizardScreen { - private SearchContainer searchContainer; + private SearchContainer searchContainer = null!; [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -91,13 +88,11 @@ namespace osu.Game.Overlays.FirstRunSetup new GraphicsSection(), new OnlineSection(), new MaintenanceSection(), + new DebugSection() }, SearchTerm = SettingsItem.CLASSIC_DEFAULT_SEARCH_TERM, } }; - - if (DebugUtils.IsDebugBuild) - searchContainer.Add(new DebugSection()); } private void applyClassic() diff --git a/osu.Game/Overlays/Settings/Sections/DebugSection.cs b/osu.Game/Overlays/Settings/Sections/DebugSection.cs index 1d2129413c..37fab9cac3 100644 --- a/osu.Game/Overlays/Settings/Sections/DebugSection.cs +++ b/osu.Game/Overlays/Settings/Sections/DebugSection.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; @@ -20,12 +21,12 @@ namespace osu.Game.Overlays.Settings.Sections public DebugSection() { - Children = new Drawable[] - { - new GeneralSettings(), - new BatchImportSettings(), - new MemorySettings(), - }; + Add(new GeneralSettings()); + + if (DebugUtils.IsDebugBuild) + Add(new BatchImportSettings()); + + Add(new MemorySettings()); } } } diff --git a/osu.Game/Overlays/Settings/Sections/DebugSettings/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/DebugSettings/GeneralSettings.cs index bd6ada4ca7..3251b93d9f 100644 --- a/osu.Game/Overlays/Settings/Sections/DebugSettings/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/DebugSettings/GeneralSettings.cs @@ -3,7 +3,7 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; -using osu.Framework.Graphics; +using osu.Framework.Development; using osu.Framework.Localisation; namespace osu.Game.Overlays.Settings.Sections.DebugSettings @@ -15,19 +15,20 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings [BackgroundDependencyLoader] private void load(FrameworkDebugConfigManager config, FrameworkConfigManager frameworkConfig) { - Children = new Drawable[] + Add(new SettingsCheckbox { - new SettingsCheckbox - { - LabelText = @"Show log overlay", - Current = frameworkConfig.GetBindable(FrameworkSetting.ShowLogOverlay) - }, - new SettingsCheckbox + LabelText = @"Show log overlay", + Current = frameworkConfig.GetBindable(FrameworkSetting.ShowLogOverlay) + }); + + if (DebugUtils.IsDebugBuild) + { + Add(new SettingsCheckbox { LabelText = @"Bypass front-to-back render pass", Current = config.GetBindable(DebugSetting.BypassFrontToBackPass) - }, - }; + }); + } } } } diff --git a/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs b/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs index b693822838..1272d1396c 100644 --- a/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs +++ b/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs @@ -5,6 +5,7 @@ using System; using System.Threading; using System.Threading.Tasks; using osu.Framework.Allocation; +using osu.Framework.Development; using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Localisation; @@ -24,73 +25,77 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings SettingsButton blockAction; SettingsButton unblockAction; - Children = new Drawable[] + Add(new SettingsButton { - new SettingsButton + Text = @"Clear all caches", + Action = host.Collect + }); + + if (DebugUtils.IsDebugBuild) + { + AddRange(new Drawable[] { - Text = @"Clear all caches", - Action = host.Collect - }, - new SettingsButton - { - Text = @"Compact realm", - Action = () => + new SettingsButton { - // Blocking operations implicitly causes a Compact(). - using (realm.BlockAllOperations(@"compact")) + Text = @"Compact realm", + Action = () => { + // Blocking operations implicitly causes a Compact(). + using (realm.BlockAllOperations(@"compact")) + { + } + } + }, + blockAction = new SettingsButton + { + Text = @"Block realm", + }, + unblockAction = new SettingsButton + { + Text = @"Unblock realm", + } + }); + + blockAction.Action = () => + { + try + { + IDisposable? token = realm.BlockAllOperations(@"maintenance"); + + blockAction.Enabled.Value = false; + + // As a safety measure, unblock after 10 seconds. + // This is to handle the case where a dev may block, but then something on the update thread + // accesses realm and blocks for eternity. + Task.Factory.StartNew(() => + { + Thread.Sleep(10000); + unblock(); + }); + + unblockAction.Action = unblock; + + void unblock() + { + if (token.IsNull()) + return; + + token.Dispose(); + token = null; + + Scheduler.Add(() => + { + blockAction.Enabled.Value = true; + unblockAction.Action = null; + }); } } - }, - blockAction = new SettingsButton - { - Text = @"Block realm", - }, - unblockAction = new SettingsButton - { - Text = @"Unblock realm", - }, - }; - - blockAction.Action = () => - { - try - { - IDisposable? token = realm.BlockAllOperations(@"maintenance"); - - blockAction.Enabled.Value = false; - - // As a safety measure, unblock after 10 seconds. - // This is to handle the case where a dev may block, but then something on the update thread - // accesses realm and blocks for eternity. - Task.Factory.StartNew(() => + catch (Exception e) { - Thread.Sleep(10000); - unblock(); - }); - - unblockAction.Action = unblock; - - void unblock() - { - if (token.IsNull()) - return; - - token.Dispose(); - token = null; - - Scheduler.Add(() => - { - blockAction.Enabled.Value = true; - unblockAction.Action = null; - }); + Logger.Error(e, @"Blocking realm failed"); } - } - catch (Exception e) - { - Logger.Error(e, @"Blocking realm failed"); - } - }; + }; + } } } } diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index a498f2fe1f..3065a4d1bd 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -31,7 +30,7 @@ namespace osu.Game.Overlays protected override IEnumerable CreateSections() { - var sections = new List + return new List { // This list should be kept in sync with ScreenBehaviour. new GeneralSection(), @@ -44,12 +43,8 @@ namespace osu.Game.Overlays new GraphicsSection(), new OnlineSection(), new MaintenanceSection(), + new DebugSection() }; - - if (DebugUtils.IsDebugBuild) - sections.Add(new DebugSection()); - - return sections; } private readonly List subPanels = new List(); From adc054f08eece15c0e9f002d7c27826c4a8de347 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 15 Jul 2025 10:25:42 +0900 Subject: [PATCH 2/5] Clear caches as aggressively as possible --- .../Settings/Sections/DebugSettings/MemorySettings.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs b/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs index 1272d1396c..0c060197bf 100644 --- a/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs +++ b/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs @@ -28,7 +28,13 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings Add(new SettingsButton { Text = @"Clear all caches", - Action = host.Collect + Action = () => + { + host.Collect(); + + // host.Collect() uses GCCollectionMode.Optimized, but we should be as aggressive as possible here. + GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true, true); + } }); if (DebugUtils.IsDebugBuild) From 1c243b25b23127ddfc47c02bdd31ff9d96b975f8 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 15 Jul 2025 11:07:37 +0900 Subject: [PATCH 3/5] Add GC mode dropdown --- .../Sections/DebugSettings/MemorySettings.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs b/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs index 0c060197bf..4b9ed22c29 100644 --- a/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs +++ b/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Runtime; using System.Threading; using System.Threading.Tasks; using osu.Framework.Allocation; @@ -37,6 +38,27 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings } }); + SettingsEnumDropdown latencyModeDropdown; + Add(latencyModeDropdown = new SettingsEnumDropdown + { + LabelText = "GC mode", + }); + + latencyModeDropdown.Current.BindValueChanged(mode => + { + switch (mode.NewValue) + { + case GCLatencyMode.Default: + // https://github.com/ppy/osu-framework/blob/1d5301018dfed1a28702be56e1d53c4835b199f2/osu.Framework/Platform/GameHost.cs#L703 + GCSettings.LatencyMode = System.Runtime.GCLatencyMode.SustainedLowLatency; + break; + + case GCLatencyMode.Interactive: + GCSettings.LatencyMode = System.Runtime.GCLatencyMode.Interactive; + break; + } + }); + if (DebugUtils.IsDebugBuild) { AddRange(new Drawable[] @@ -103,5 +125,11 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings }; } } + + private enum GCLatencyMode + { + Default, + Interactive, + } } } From a80a9bbfd10719b321a4f319125b8b33bfc0cef0 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 15 Jul 2025 13:44:49 +0900 Subject: [PATCH 4/5] Hide entire general section --- osu.Game/Overlays/Settings/Sections/DebugSection.cs | 5 +++-- .../Sections/DebugSettings/GeneralSettings.cs | 12 ++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/DebugSection.cs b/osu.Game/Overlays/Settings/Sections/DebugSection.cs index 37fab9cac3..969e65e823 100644 --- a/osu.Game/Overlays/Settings/Sections/DebugSection.cs +++ b/osu.Game/Overlays/Settings/Sections/DebugSection.cs @@ -21,10 +21,11 @@ namespace osu.Game.Overlays.Settings.Sections public DebugSection() { - Add(new GeneralSettings()); - if (DebugUtils.IsDebugBuild) + { + Add(new GeneralSettings()); Add(new BatchImportSettings()); + } Add(new MemorySettings()); } diff --git a/osu.Game/Overlays/Settings/Sections/DebugSettings/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/DebugSettings/GeneralSettings.cs index 3251b93d9f..914fc9d141 100644 --- a/osu.Game/Overlays/Settings/Sections/DebugSettings/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/DebugSettings/GeneralSettings.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; -using osu.Framework.Development; using osu.Framework.Localisation; namespace osu.Game.Overlays.Settings.Sections.DebugSettings @@ -21,14 +20,11 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings Current = frameworkConfig.GetBindable(FrameworkSetting.ShowLogOverlay) }); - if (DebugUtils.IsDebugBuild) + Add(new SettingsCheckbox { - Add(new SettingsCheckbox - { - LabelText = @"Bypass front-to-back render pass", - Current = config.GetBindable(DebugSetting.BypassFrontToBackPass) - }); - } + LabelText = @"Bypass front-to-back render pass", + Current = config.GetBindable(DebugSetting.BypassFrontToBackPass) + }); } } } From 985241c63ea3b740480b8988827d024849b83887 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 15 Jul 2025 13:44:58 +0900 Subject: [PATCH 5/5] Log changes to latency mode --- .../Overlays/Settings/Sections/DebugSettings/MemorySettings.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs b/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs index 4b9ed22c29..7b9b88a213 100644 --- a/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs +++ b/osu.Game/Overlays/Settings/Sections/DebugSettings/MemorySettings.cs @@ -46,6 +46,8 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings latencyModeDropdown.Current.BindValueChanged(mode => { + Logger.Log($"Changing latency mode: {mode.NewValue}"); + switch (mode.NewValue) { case GCLatencyMode.Default: