Skip to content

Commit

Permalink
Merge pull request #18914 from peppy/spectator-playback-test-leniences
Browse files Browse the repository at this point in the history
Increase leniences on `TestSceneSpectatorPlayback.TestWithSendFailure`
  • Loading branch information
smoogipoo authored Jun 28, 2022
2 parents 2f264aa + 22b254e commit 8e4a6c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 7 additions & 2 deletions osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,16 @@ public void TestWithSendFailure()
AddStep("start failing sends", () =>
{
spectatorClient.ShouldFailSendingFrames = true;
framesReceivedSoFar = replay.Frames.Count;
frameSendAttemptsSoFar = spectatorClient.FrameSendAttempts;
});

AddUntilStep("wait for send attempts", () => spectatorClient.FrameSendAttempts > frameSendAttemptsSoFar + 5);
AddUntilStep("wait for next send attempt", () =>
{
framesReceivedSoFar = replay.Frames.Count;
return spectatorClient.FrameSendAttempts > frameSendAttemptsSoFar + 1;
});

AddUntilStep("wait for more send attempts", () => spectatorClient.FrameSendAttempts > frameSendAttemptsSoFar + 10);
AddAssert("frames did not increase", () => framesReceivedSoFar == replay.Frames.Count);

AddStep("stop failing sends", () => spectatorClient.ShouldFailSendingFrames = false);
Expand Down
18 changes: 11 additions & 7 deletions osu.Game/Online/Spectator/SpectatorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,21 @@ private void sendNextBundleIfRequired()

lastSend = tcs.Task;

SendFramesInternal(bundle).ContinueWith(t => Schedule(() =>
SendFramesInternal(bundle).ContinueWith(t =>
{
// Handle exception outside of `Schedule` to ensure it doesn't go unovserved.
bool wasSuccessful = t.Exception == null;

// If the last bundle send wasn't successful, try again without dequeuing.
if (wasSuccessful)
pendingFrameBundles.Dequeue();
return Schedule(() =>
{
// If the last bundle send wasn't successful, try again without dequeuing.
if (wasSuccessful)
pendingFrameBundles.Dequeue();

tcs.SetResult(wasSuccessful);
sendNextBundleIfRequired();
}));
tcs.SetResult(wasSuccessful);
sendNextBundleIfRequired();
});
});
}
}
}

0 comments on commit 8e4a6c4

Please sign in to comment.