From 565ae99e0dfddbecef6bc24828ba6c39c837f5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 26 Oct 2023 19:27:50 +0200 Subject: [PATCH] Fix `StopUsingBeatmapClock()` applying adjustments to track it was supposed to stop using - Closes https://github.com/ppy/osu/issues/25248 - Possibly also closes https://github.com/ppy/osu/issues/20475 Regressed in e33486a766044c17c2f254f5e8df6d72b29c341e. `StopUsingBeatmapClock()` intends to, as the name says, stop operating on the working beatmap clock to yield its usage to other components on exit. As part of that it tries to unapply audio adjustments so that other screens can apply theirs freely instead. However, the aforementioned commit introduced a bug in this. Previously to it, `track` was an alias for the `SourceClock`, which could be mutated in an indirect way via `ChangeSource()` calls. The aforementioned commit made `track` a `readonly` field, initialised in constructor, which would _never_ change value. In particular, it would _always_ be the beatmap track, which meant that `StopUsingBeatmapClock()` would remove the adjustments from the beatmap track, but then at the end of the method, _apply them onto that same track again_. This was only saved by the fact that clock adjustments are removed again on disposal of the `MasterGameplayClockContainer()`. This - due to async disposal pressure - could explain infrequently reported cases wherein the track would just continue to speed up ad infinitum. To fix, fully substitute the beatmap track for a virtual track at the point of calling `StopUsingBeatmapClock()`. --- osu.Game/Screens/Play/MasterGameplayClockContainer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs index 70d9ecd3e7..6e07b01b5f 100644 --- a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs +++ b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Play private readonly WorkingBeatmap beatmap; - private readonly Track track; + private Track track; private readonly double skipTargetTime; @@ -188,11 +188,11 @@ namespace osu.Game.Screens.Play { removeSourceClockAdjustments(); - var virtualTrack = new TrackVirtual(beatmap.Track.Length); - virtualTrack.Seek(CurrentTime); + track = new TrackVirtual(beatmap.Track.Length); + track.Seek(CurrentTime); if (IsRunning) - virtualTrack.Start(); - ChangeSource(virtualTrack); + track.Start(); + ChangeSource(track); addSourceClockAdjustments(); }