1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 00:42:55 +08:00

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 e33486a766.

`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()`.
This commit is contained in:
Bartłomiej Dach 2023-10-26 19:27:50 +02:00
parent 0482c05d7c
commit 565ae99e0d
No known key found for this signature in database

View File

@ -41,7 +41,7 @@ namespace osu.Game.Screens.Play
private readonly WorkingBeatmap beatmap; private readonly WorkingBeatmap beatmap;
private readonly Track track; private Track track;
private readonly double skipTargetTime; private readonly double skipTargetTime;
@ -188,11 +188,11 @@ namespace osu.Game.Screens.Play
{ {
removeSourceClockAdjustments(); removeSourceClockAdjustments();
var virtualTrack = new TrackVirtual(beatmap.Track.Length); track = new TrackVirtual(beatmap.Track.Length);
virtualTrack.Seek(CurrentTime); track.Seek(CurrentTime);
if (IsRunning) if (IsRunning)
virtualTrack.Start(); track.Start();
ChangeSource(virtualTrack); ChangeSource(track);
addSourceClockAdjustments(); addSourceClockAdjustments();
} }