From 2707a7179e66ec67d2958772cfe99d4fdd4b6f2a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 26 Jun 2019 13:18:03 +0900 Subject: [PATCH] Fix MusiController holding references to beatmaps while inactive --- osu.Game/Overlays/MusicController.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 36937def2b..6a22ad11ff 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -259,6 +259,12 @@ namespace osu.Game.Overlays { base.Update(); + if (pendingBeatmapSwitch != null) + { + pendingBeatmapSwitch(); + pendingBeatmapSwitch = null; + } + var track = current?.TrackLoaded ?? false ? current.Track : null; if (track?.IsDummyDevice == false) @@ -368,15 +374,12 @@ namespace osu.Game.Overlays mod.ApplyToClock(track); } - private ScheduledDelegate pendingBeatmapSwitch; + private Action pendingBeatmapSwitch; private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) { - //we might be off-screen when this update comes in. - //rather than Scheduling, manually handle this to avoid possible memory contention. - pendingBeatmapSwitch?.Cancel(); - - pendingBeatmapSwitch = Schedule(delegate + // avoid using scheduler as our scheduler may not be run for a long time, holding references to beatmaps. + pendingBeatmapSwitch = delegate { // todo: this can likely be replaced with WorkingBeatmap.GetBeatmapAsync() Task.Run(() => @@ -416,7 +419,7 @@ namespace osu.Game.Overlays playerContainer.Add(newBackground); }); - }); + }; } protected override void PopIn()