Skip to content

Commit d5b9243

Browse files
committed
Log backwards seeks to sentry
1 parent 5910a24 commit d5b9243

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

osu.Game/OsuGame.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,9 @@ private void forwardGeneralLogsToNotifications()
11961196
{
11971197
if (entry.Level < LogLevel.Important || entry.Target > LoggingTarget.Database || entry.Target == null) return;
11981198

1199+
if (entry.Exception is SentryOnlyDiagnosticsException)
1200+
return;
1201+
11991202
const int short_term_display_limit = 3;
12001203

12011204
if (recentLogCount < short_term_display_limit)

osu.Game/Rulesets/UI/FrameStabilityContainer.cs

+12-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using osu.Game.Beatmaps;
1616
using osu.Game.Input.Handlers;
1717
using osu.Game.Screens.Play;
18+
using osu.Game.Utils;
1819

1920
namespace osu.Game.Rulesets.UI
2021
{
@@ -29,6 +30,7 @@ public sealed partial class FrameStabilityContainer : Container, IHasReplayHandl
2930
public ReplayInputHandler? ReplayInputHandler { get; set; }
3031

3132
public bool AllowBackwardsSeeks { get; set; }
33+
private double? lastBackwardsSeekLogTime;
3234

3335
/// <summary>
3436
/// The number of CPU milliseconds to spend at most during seek catch-up.
@@ -163,10 +165,17 @@ private void updateClock()
163165
// time should never go backwards". If it does, we stop running gameplay until it returns to normal.
164166
if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !AllowBackwardsSeeks)
165167
{
166-
Logger.Log($"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})");
168+
if (lastBackwardsSeekLogTime == null || Math.Abs(Clock.CurrentTime - lastBackwardsSeekLogTime.Value) > 1000)
169+
{
170+
lastBackwardsSeekLogTime = Clock.CurrentTime;
171+
172+
string loggableContent = $"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})";
167173

168-
if (parentGameplayClock is GameplayClockContainer gcc)
169-
Logger.Log($"{gcc.ChildrenOfType<FramedBeatmapClock>().Single().GetSnapshot()}");
174+
if (parentGameplayClock is GameplayClockContainer gcc)
175+
loggableContent += $"\n{gcc.ChildrenOfType<FramedBeatmapClock>().Single().GetSnapshot()}";
176+
177+
Logger.Error(new SentryOnlyDiagnosticsException("backwards seek"), loggableContent);
178+
}
170179

171180
state = PlaybackState.NotValid;
172181
return;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using System;
5+
6+
namespace osu.Game.Utils
7+
{
8+
/// <summary>
9+
/// Log to sentry without showing an error notification to the user.
10+
/// </summary>
11+
/// <remarks>
12+
/// This can be used to convey important diagnostics to us developers without
13+
/// getting in the user's way. Should be used sparingly.</remarks>
14+
internal class SentryOnlyDiagnosticsException : Exception
15+
{
16+
public SentryOnlyDiagnosticsException(string message)
17+
: base(message)
18+
{
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)