mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 03:42:57 +08:00
Log backwards seeks to sentry
This commit is contained in:
parent
59b9d29a79
commit
19ed78eef5
@ -1190,6 +1190,9 @@ namespace osu.Game
|
||||
{
|
||||
if (entry.Level < LogLevel.Important || entry.Target > LoggingTarget.Database || entry.Target == null) return;
|
||||
|
||||
if (entry.Exception is SentryOnlyDiagnosticsException)
|
||||
return;
|
||||
|
||||
const int short_term_display_limit = 3;
|
||||
|
||||
if (recentLogCount < short_term_display_limit)
|
||||
|
@ -15,6 +15,7 @@ using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Input.Handlers;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Utils;
|
||||
|
||||
namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
@ -29,6 +30,7 @@ namespace osu.Game.Rulesets.UI
|
||||
public ReplayInputHandler? ReplayInputHandler { get; set; }
|
||||
|
||||
public bool AllowBackwardsSeeks { get; set; }
|
||||
private double? lastBackwardsSeekLogTime;
|
||||
|
||||
/// <summary>
|
||||
/// The number of CPU milliseconds to spend at most during seek catch-up.
|
||||
@ -163,10 +165,17 @@ namespace osu.Game.Rulesets.UI
|
||||
// time should never go backwards". If it does, we stop running gameplay until it returns to normal.
|
||||
if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !AllowBackwardsSeeks)
|
||||
{
|
||||
Logger.Log($"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})");
|
||||
if (lastBackwardsSeekLogTime == null || Math.Abs(Clock.CurrentTime - lastBackwardsSeekLogTime.Value) > 1000)
|
||||
{
|
||||
lastBackwardsSeekLogTime = Clock.CurrentTime;
|
||||
|
||||
if (parentGameplayClock is GameplayClockContainer gcc)
|
||||
Logger.Log($"{gcc.ChildrenOfType<FramedBeatmapClock>().Single().GetSnapshot()}");
|
||||
string loggableContent = $"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})";
|
||||
|
||||
if (parentGameplayClock is GameplayClockContainer gcc)
|
||||
loggableContent += $"\n{gcc.ChildrenOfType<FramedBeatmapClock>().Single().GetSnapshot()}";
|
||||
|
||||
Logger.Error(new SentryOnlyDiagnosticsException("backwards seek"), loggableContent);
|
||||
}
|
||||
|
||||
state = PlaybackState.NotValid;
|
||||
return;
|
||||
|
21
osu.Game/Utils/SentryOnlyDiagnosticsException.cs
Normal file
21
osu.Game/Utils/SentryOnlyDiagnosticsException.cs
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Log to sentry without showing an error notification to the user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This can be used to convey important diagnostics to us developers without
|
||||
/// getting in the user's way. Should be used sparingly.</remarks>
|
||||
internal class SentryOnlyDiagnosticsException : Exception
|
||||
{
|
||||
public SentryOnlyDiagnosticsException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user