Fix intermittent failure in tests with restarting player instances

This commit is contained in:
Salman Ahmed
2023-01-15 15:51:18 +03:00
parent 8f70424999
commit 13c1b8f5a4
5 changed files with 28 additions and 5 deletions

View File

@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Screens;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Online.Spectator;
@ -103,6 +104,19 @@ namespace osu.Game.Tests.Visual
ScoreProcessor.NewJudgement += r => Results.Add(r);
}
public override bool OnExiting(ScreenExitEvent e)
{
bool exiting = base.OnExiting(e);
// SubmittingPlayer performs EndPlaying on a fire-and-forget async task, which allows for the chance of BeginPlaying to be called before EndPlaying is called here.
// Until this is handled properly at game-side, ensure EndPlaying is called before exiting player.
// see: https://github.com/ppy/osu/issues/22220
if (LoadedBeatmapSuccessfully)
spectatorClient?.EndPlaying(GameplayState);
return exiting;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);