Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StopUsingBeatmapClock() applying adjustments to track it was supposed to stop using #25253

Merged
merged 3 commits into from
Oct 27, 2023

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Oct 26, 2023

Regressed in e33486a.

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().

bdach added 3 commits October 26, 2023 19:38
…pposed to stop using

- Closes ppy#25248
- Possibly also closes ppy#20475

Regressed in e33486a.

`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()`.
Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch...

@peppy peppy merged commit 344bb28 into ppy:master Oct 27, 2023
@bdach bdach deleted the fix-double-adjustment-application branch October 27, 2023 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants