1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 03:42:57 +08:00

Add comprehensive log output to help figure out problematic clocks

This commit is contained in:
Dean Herbert 2024-02-29 23:03:27 +08:00
parent 4184a5c1ef
commit cc8b838bd4
No known key found for this signature in database
2 changed files with 32 additions and 1 deletions

View File

@ -38,6 +38,7 @@ namespace osu.Game.Beatmaps
private IDisposable? beatmapOffsetSubscription;
private readonly DecouplingFramedClock decoupledTrack;
private readonly InterpolatingFramedClock interpolatedTrack;
[Resolved]
private OsuConfigManager config { get; set; } = null!;
@ -58,7 +59,7 @@ namespace osu.Game.Beatmaps
// An interpolating clock is used to ensure precise time values even when the host audio subsystem is not reporting
// high precision times (on windows there's generally only 5-10ms reporting intervals, as an example).
var interpolatedTrack = new InterpolatingFramedClock(decoupledTrack);
interpolatedTrack = new InterpolatingFramedClock(decoupledTrack);
if (applyOffsets)
{
@ -190,5 +191,28 @@ namespace osu.Game.Beatmaps
base.Dispose(isDisposing);
beatmapOffsetSubscription?.Dispose();
}
public string GetSnapshot()
{
return
$"originalSource: {output(Source)}\n" +
$"userGlobalOffsetClock: {output(userGlobalOffsetClock)}\n" +
$"platformOffsetClock: {output(platformOffsetClock)}\n" +
$"userBeatmapOffsetClock: {output(userBeatmapOffsetClock)}\n" +
$"interpolatedTrack: {output(interpolatedTrack)}\n" +
$"decoupledTrack: {output(decoupledTrack)}\n" +
$"finalClockSource: {output(finalClockSource)}\n";
string output(IClock? clock)
{
if (clock == null)
return "null";
if (clock is IFrameBasedClock framed)
return $"current: {clock.CurrentTime:N2} running: {clock.IsRunning} rate: {clock.Rate} elapsed: {framed.ElapsedFrameTime:N2}";
return $"current: {clock.CurrentTime:N2} running: {clock.IsRunning} rate: {clock.Rate}";
}
}
}
}

View File

@ -3,13 +3,16 @@
using System;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;
using osu.Framework.Testing;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Input.Handlers;
using osu.Game.Screens.Play;
@ -161,6 +164,10 @@ namespace osu.Game.Rulesets.UI
if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !AllowBackwardsSeeks)
{
Logger.Log($"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})");
if (parentGameplayClock is GameplayClockContainer gcc)
Logger.Log($"{gcc.ChildrenOfType<FramedBeatmapClock>().Single().GetSnapshot()}");
state = PlaybackState.NotValid;
return;
}