mirror of
https://github.com/ppy/osu.git
synced 2026-05-18 14:01:24 +08:00
809298ddeb
## [Rewrite `BackgroundMusicManager` to not run into framework breakage](https://github.com/ppy/osu/commit/622216d8911832c39fa4e126b2810e4e0f46cbf7) The attempted proper fix to this was https://github.com/ppy/osu-framework/pull/6727. Unfortunately when presented with [the framework bump](https://github.com/ppy/osu/pull/37217) with that change, CI says "you're stupid" and fails on some disposal idiocy that of course is undebuggable and irreproducible: The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object. at osu.Framework.Audio.Sample.SampleChannelBass.Dispose(Boolean disposing) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of inner exception stack trace --- at osu.Framework.Audio.AudioCollectionManager`1.UpdateChildren() at osu.Framework.Audio.AudioCollectionManager`1.UpdateChildren() at osu.Framework.Audio.AudioCollectionManager`1.UpdateChildren() at osu.Framework.Audio.AudioCollectionManager`1.UpdateChildren() at osu.Framework.Threading.AudioThread.OnExit() at osu.Framework.Threading.GameThread.setExitState(GameThreadState exitState) at osu.Framework.Threading.GameThread.RunSingleFrame() at osu.Framework.Threading.GameThread.<createThread>g__runWork|70_0() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) (https://github.com/ppy/osu/actions/runs/24019928154/job/70046733058?pr=37217#step:5:119) I no longer have the energy for any of this shit. @nekodex would appreciate if you could check that I actually haven't broken anything with the bgm here. Seems okay to me in test scenes at least. ## [Apply lowest-effort maybe-fixing changes to a bunch of flaking tests](https://github.com/ppy/osu/commit/7bd3ca4adfcce5b90add11565a13f3fe9177ad5e) None of the failures are reproducible locally, of course. I'm tired of this. If anyone else wants to subject themselves to actually investigating any of these, by all means, godspeed and good luck.
91 lines
3.5 KiB
C#
91 lines
3.5 KiB
C#
// 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.Collections.Generic;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using osu.Framework.Testing;
|
|
using osu.Game.Audio;
|
|
using osu.Game.Rulesets;
|
|
using osu.Game.Rulesets.Osu;
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
using osu.Game.Skinning;
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
{
|
|
public partial class TestSceneGameplaySamplePlayback : PlayerTestScene
|
|
{
|
|
protected override bool AllowBackwardsSeeks => true;
|
|
|
|
private bool seek;
|
|
|
|
[Test]
|
|
[Ignore("Still failing even with [FlakyTest] applied.")]
|
|
public void TestAllSamplesStopDuringSeek()
|
|
{
|
|
DrawableSlider? slider = null;
|
|
PoolableSkinnableSample[] samples = null!;
|
|
ISamplePlaybackDisabler sampleDisabler = null!;
|
|
|
|
AddUntilStep("get variables", () =>
|
|
{
|
|
sampleDisabler = Player;
|
|
slider = Player.ChildrenOfType<DrawableSlider>().MinBy(s => s.HitObject.StartTime);
|
|
samples = slider.ChildrenOfType<PoolableSkinnableSample>().ToArray();
|
|
|
|
return slider != null;
|
|
});
|
|
|
|
AddUntilStep("wait for slider sliding then seek", () =>
|
|
{
|
|
if (slider?.Tracking.Value != true)
|
|
return false;
|
|
|
|
if (!samples.Any(s => s.Playing))
|
|
return false;
|
|
|
|
seek = true;
|
|
return true;
|
|
});
|
|
|
|
AddUntilStep("sample playback disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);
|
|
|
|
// because we are in frame stable context, it's quite likely that not all samples are "played" at this point.
|
|
// the important thing is that at least one started, and that sample has since stopped.
|
|
AddAssert("all looping samples stopped immediately", () => allStopped(allLoopingSounds));
|
|
AddUntilStep("all samples stopped eventually", () => allStopped(allSounds));
|
|
|
|
AddAssert("sample playback still disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);
|
|
|
|
AddStep("stop seeking", () => seek = false);
|
|
|
|
AddUntilStep("seek finished, sample playback enabled", () => !sampleDisabler.SamplePlaybackDisabled.Value);
|
|
AddUntilStep("any sample is playing", () => Player.ChildrenOfType<PausableSkinnableSound>().Any(s => s.IsPlaying));
|
|
}
|
|
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
|
|
if (seek)
|
|
{
|
|
// Frame stable playback is too fast to catch up these days.
|
|
//
|
|
// We want to keep seeking while asserting various test conditions, so
|
|
// continue to seek until we unset the flag.
|
|
var gameplayClockContainer = Player?.GameplayClockContainer;
|
|
gameplayClockContainer?.Seek(gameplayClockContainer.CurrentTime > 30000 ? 0 : 60000);
|
|
}
|
|
}
|
|
|
|
private IEnumerable<PausableSkinnableSound> allSounds => Player.ChildrenOfType<PausableSkinnableSound>();
|
|
private IEnumerable<PausableSkinnableSound> allLoopingSounds => allSounds.Where(sound => sound.Looping);
|
|
|
|
private bool allStopped(IEnumerable<PausableSkinnableSound> sounds) => sounds.All(sound => !sound.IsPlaying);
|
|
|
|
protected override bool Autoplay => true;
|
|
|
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
|
}
|
|
}
|