1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 05:22:54 +08:00

Only attempt to disable rulesets when decidedly crashing out

This commit is contained in:
Bartłomiej Dach 2024-03-25 11:33:15 +01:00
parent c7c0330265
commit fb08d6816b
No known key found for this signature in database

View File

@ -678,18 +678,21 @@ namespace osu.Game
/// <summary>
/// Allows a maximum of one unhandled exception, per second of execution.
/// </summary>
/// <returns>Whether to ignore the exception and continue running.</returns>
private bool onExceptionThrown(Exception ex)
{
bool continueExecution = Interlocked.Decrement(ref allowableExceptions) >= 0;
Logger.Log($"Unhandled exception has been {(continueExecution ? $"allowed with {allowableExceptions} more allowable exceptions" : "denied")} .");
RulesetStore.TryDisableCustomRulesetsCausing(ex);
if (Interlocked.Decrement(ref allowableExceptions) < 0)
{
Logger.Log("Too many unhandled exceptions, crashing out.");
RulesetStore.TryDisableCustomRulesetsCausing(ex);
return false;
}
Logger.Log($"Unhandled exception has been allowed with {allowableExceptions} more allowable exceptions.");
// restore the stock of allowable exceptions after a short delay.
Task.Delay(1000).ContinueWith(_ => Interlocked.Increment(ref allowableExceptions));
return continueExecution;
return true;
}
protected override void Dispose(bool isDisposing)