1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-21 01:39:54 +08:00

Merge pull request #34221 from smoogipoo/debug-settings

Bring back minimal debug settings
This commit is contained in:
Dean Herbert
2025-07-15 14:01:43 +09:00
committed by GitHub
Unverified
5 changed files with 120 additions and 90 deletions
@@ -1,11 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<SettingsSection> searchContainer;
private SearchContainer<SettingsSection> 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<bool>.CLASSIC_DEFAULT_SEARCH_TERM,
}
};
if (DebugUtils.IsDebugBuild)
searchContainer.Add(new DebugSection());
}
private void applyClassic()
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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,13 @@ namespace osu.Game.Overlays.Settings.Sections
public DebugSection()
{
Children = new Drawable[]
if (DebugUtils.IsDebugBuild)
{
new GeneralSettings(),
new BatchImportSettings(),
new MemorySettings(),
};
Add(new GeneralSettings());
Add(new BatchImportSettings());
}
Add(new MemorySettings());
}
}
}
@@ -3,7 +3,6 @@
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
namespace osu.Game.Overlays.Settings.Sections.DebugSettings
@@ -15,19 +14,17 @@ 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<bool>(FrameworkSetting.ShowLogOverlay)
},
new SettingsCheckbox
{
LabelText = @"Bypass front-to-back render pass",
Current = config.GetBindable<bool>(DebugSetting.BypassFrontToBackPass)
},
};
LabelText = @"Show log overlay",
Current = frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowLogOverlay)
});
Add(new SettingsCheckbox
{
LabelText = @"Bypass front-to-back render pass",
Current = config.GetBindable<bool>(DebugSetting.BypassFrontToBackPass)
});
}
}
}
@@ -2,9 +2,11 @@
// 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;
using osu.Framework.Development;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
@@ -24,73 +26,112 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
SettingsButton blockAction;
SettingsButton unblockAction;
Children = new Drawable[]
Add(new SettingsButton
{
new SettingsButton
Text = @"Clear all caches",
Action = () =>
{
Text = @"Clear all caches",
Action = host.Collect
},
new SettingsButton
host.Collect();
// host.Collect() uses GCCollectionMode.Optimized, but we should be as aggressive as possible here.
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true, true);
}
});
SettingsEnumDropdown<GCLatencyMode> latencyModeDropdown;
Add(latencyModeDropdown = new SettingsEnumDropdown<GCLatencyMode>
{
LabelText = "GC mode",
});
latencyModeDropdown.Current.BindValueChanged(mode =>
{
Logger.Log($"Changing latency mode: {mode.NewValue}");
switch (mode.NewValue)
{
Text = @"Compact realm",
Action = () =>
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[]
{
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");
}
};
};
}
}
private enum GCLatencyMode
{
Default,
Interactive,
}
}
}
+2 -7
View File
@@ -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<SettingsSection> CreateSections()
{
var sections = new List<SettingsSection>
return new List<SettingsSection>
{
// 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<SettingsSubPanel> subPanels = new List<SettingsSubPanel>();