Skip to content

Commit ba503b7

Browse files
committed
Add comprehensive log output to help figure out problematic clocks
1 parent e778832 commit ba503b7

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

osu.Game/Beatmaps/FramedBeatmapClock.cs

+25-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public partial class FramedBeatmapClock : Component, IFrameBasedClock, IAdjustab
3838
private IDisposable? beatmapOffsetSubscription;
3939

4040
private readonly DecouplingFramedClock decoupledTrack;
41+
private readonly InterpolatingFramedClock interpolatedTrack;
4142

4243
[Resolved]
4344
private OsuConfigManager config { get; set; } = null!;
@@ -58,7 +59,7 @@ public FramedBeatmapClock(bool applyOffsets, bool requireDecoupling, IClock? sou
5859

5960
// An interpolating clock is used to ensure precise time values even when the host audio subsystem is not reporting
6061
// high precision times (on windows there's generally only 5-10ms reporting intervals, as an example).
61-
var interpolatedTrack = new InterpolatingFramedClock(decoupledTrack);
62+
interpolatedTrack = new InterpolatingFramedClock(decoupledTrack);
6263

6364
if (applyOffsets)
6465
{
@@ -190,5 +191,28 @@ protected override void Dispose(bool isDisposing)
190191
base.Dispose(isDisposing);
191192
beatmapOffsetSubscription?.Dispose();
192193
}
194+
195+
public string GetSnapshot()
196+
{
197+
return
198+
$"originalSource: {output(Source)}\n" +
199+
$"userGlobalOffsetClock: {output(userGlobalOffsetClock)}\n" +
200+
$"platformOffsetClock: {output(platformOffsetClock)}\n" +
201+
$"userBeatmapOffsetClock: {output(userBeatmapOffsetClock)}\n" +
202+
$"interpolatedTrack: {output(interpolatedTrack)}\n" +
203+
$"decoupledTrack: {output(decoupledTrack)}\n" +
204+
$"finalClockSource: {output(finalClockSource)}\n";
205+
206+
string output(IClock? clock)
207+
{
208+
if (clock == null)
209+
return "null";
210+
211+
if (clock is IFrameBasedClock framed)
212+
return $"current: {clock.CurrentTime:N2} running: {clock.IsRunning} rate: {clock.Rate} elapsed: {framed.ElapsedFrameTime:N2}";
213+
214+
return $"current: {clock.CurrentTime:N2} running: {clock.IsRunning} rate: {clock.Rate}";
215+
}
216+
}
193217
}
194218
}

osu.Game/Rulesets/UI/FrameStabilityContainer.cs

+7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33

44
using System;
55
using System.Diagnostics;
6+
using System.Linq;
67
using osu.Framework.Allocation;
78
using osu.Framework.Audio;
89
using osu.Framework.Bindables;
910
using osu.Framework.Graphics;
1011
using osu.Framework.Graphics.Containers;
1112
using osu.Framework.Logging;
13+
using osu.Framework.Testing;
1214
using osu.Framework.Timing;
15+
using osu.Game.Beatmaps;
1316
using osu.Game.Input.Handlers;
1417
using osu.Game.Screens.Play;
1518

@@ -161,6 +164,10 @@ private void updateClock()
161164
if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !AllowBackwardsSeeks)
162165
{
163166
Logger.Log($"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})");
167+
168+
if (parentGameplayClock is GameplayClockContainer gcc)
169+
Logger.Log($"{gcc.ChildrenOfType<FramedBeatmapClock>().Single().GetSnapshot()}");
170+
164171
state = PlaybackState.NotValid;
165172
return;
166173
}

0 commit comments

Comments
 (0)