From f6956fc51c00520d3027ecae70a88c1bf0a74df5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 9 Feb 2017 11:28:13 +0900 Subject: [PATCH 1/2] Fix MusicController doing work in the background when not visible. --- osu.Game/Overlays/MusicController.cs | 78 ++++++++++++++++------------ 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 034278a2ef..0e0abb12bc 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -23,6 +23,7 @@ using osu.Game.Database; using osu.Game.Graphics; using osu.Framework.Graphics.Primitives; +using osu.Framework.Threading; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays @@ -229,6 +230,12 @@ protected override void Update() { base.Update(); + if (pendingBeatmapSwitch != null) + { + pendingBeatmapSwitch(); + pendingBeatmapSwitch = null; + } + if (current?.TrackLoaded ?? false) { @@ -320,43 +327,50 @@ protected override void PerformLoad(BaseGame game) base.PerformLoad(game); } + Action pendingBeatmapSwitch; + private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) { - Task.Run(() => + //we might be off-screen when this update comes in. + //rather than Scheduling, manually handle this to avoid possible memory contention. + pendingBeatmapSwitch = () => { - if (beatmap?.Beatmap == null) - //todo: we may need to display some default text here (currently in the constructor). - return; - - BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; - title.Text = unicodeString(metadata.Title, metadata.TitleUnicode); - artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode); - }); - - MusicControllerBackground newBackground; - - (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate - { - - dragContainer.Add(newBackground); - - switch (direction) + Task.Run(() => { - case TransformDirection.Next: - newBackground.Position = new Vector2(400, 0); - newBackground.MoveToX(0, 500, EasingTypes.OutCubic); - backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic); - break; - case TransformDirection.Prev: - newBackground.Position = new Vector2(-400, 0); - newBackground.MoveToX(0, 500, EasingTypes.OutCubic); - backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic); - break; - } + if (beatmap?.Beatmap == null) + //todo: we may need to display some default text here (currently in the constructor). + return; - backgroundSprite.Expire(); - backgroundSprite = newBackground; - }); + BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; + title.Text = unicodeString(metadata.Title, metadata.TitleUnicode); + artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode); + }); + + MusicControllerBackground newBackground; + + (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate + { + + dragContainer.Add(newBackground); + + switch (direction) + { + case TransformDirection.Next: + newBackground.Position = new Vector2(400, 0); + newBackground.MoveToX(0, 500, EasingTypes.OutCubic); + backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic); + break; + case TransformDirection.Prev: + newBackground.Position = new Vector2(-400, 0); + newBackground.MoveToX(0, 500, EasingTypes.OutCubic); + backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic); + break; + } + + backgroundSprite.Expire(); + backgroundSprite = newBackground; + }); + }; } private Func unicodeString; From 4337c6663184b6bdfe45fd705855baefa53bc62f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 9 Feb 2017 11:45:30 +0900 Subject: [PATCH 2/2] Framework update. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index b5c6c38245..737cf6055f 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit b5c6c38245730f80ca9db4793e106f31760dc62d +Subproject commit 737cf6055f12f8cb3154bbdbcb31f3e998809afd