1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00

Stop background processing from running when inside a high performance session

This commit is contained in:
Dean Herbert 2024-04-16 09:51:58 +08:00
parent d89edd2b4f
commit a651cb8d50
No known key found for this signature in database

View File

@ -16,6 +16,7 @@ using osu.Game.Extensions;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Performance;
using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Scoring.Legacy;
@ -51,6 +52,9 @@ namespace osu.Game.Database
[Resolved]
private ILocalUserPlayInfo? localUserPlayInfo { get; set; }
[Resolved]
private IHighPerformanceSessionManager? highPerformanceSessionManager { get; set; }
[Resolved]
private INotificationOverlay? notificationOverlay { get; set; }
@ -493,7 +497,9 @@ namespace osu.Game.Database
private void sleepIfRequired()
{
while (localUserPlayInfo?.IsPlaying.Value == true)
// Importantly, also sleep if high performance session is active.
// If we don't do this, memory usage can become runaway due to GC running in a more lenient mode.
while (localUserPlayInfo?.IsPlaying.Value == true || highPerformanceSessionManager?.IsSessionActive == true)
{
Logger.Log("Background processing sleeping due to active gameplay...");
Thread.Sleep(TimeToSleepDuringGameplay);