diff --git a/osu.Game/Beatmaps/IWorkingBeatmap.cs b/osu.Game/Beatmaps/IWorkingBeatmap.cs
index 5e9b77392a..6bf338db59 100644
--- a/osu.Game/Beatmaps/IWorkingBeatmap.cs
+++ b/osu.Game/Beatmaps/IWorkingBeatmap.cs
@@ -92,10 +92,10 @@ namespace osu.Game.Beatmaps
///
/// The to create a playable for.
/// The s to apply to the .
- /// Cancellation token that cancels the beatmap loading process.
+ /// Cancellation token that cancels the beatmap loading process. If not provided, a default timeout of 10,000ms will be applied to the load process.
/// The converted .
/// If could not be converted to .
- IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList mods = null, CancellationToken cancellationToken = default);
+ IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList mods = null, CancellationToken? cancellationToken = null);
///
/// Load a new audio track instance for this beatmap. This should be called once before accessing .
diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs
index 9be239e3b0..a04345ec5c 100644
--- a/osu.Game/Beatmaps/WorkingBeatmap.cs
+++ b/osu.Game/Beatmaps/WorkingBeatmap.cs
@@ -78,8 +78,9 @@ namespace osu.Game.Beatmaps
/// The applicable .
protected virtual IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset) => ruleset.CreateBeatmapConverter(beatmap);
- public virtual IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList mods = null, CancellationToken cancellationToken = default)
+ public virtual IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList mods = null, CancellationToken? cancellationToken = null)
{
+ var token = cancellationToken ?? new CancellationTokenSource(10000).Token;
mods ??= Array.Empty();
var rulesetInstance = ruleset.CreateInstance();
@@ -96,19 +97,19 @@ namespace osu.Game.Beatmaps
// Apply conversion mods
foreach (var mod in mods.OfType())
{
- if (cancellationToken.IsCancellationRequested)
+ if (token.IsCancellationRequested)
throw new BeatmapLoadTimeoutException(BeatmapInfo);
mod.ApplyToBeatmapConverter(converter);
}
// Convert
- IBeatmap converted = converter.Convert(cancellationToken);
+ IBeatmap converted = converter.Convert(token);
// Apply conversion mods to the result
foreach (var mod in mods.OfType())
{
- if (cancellationToken.IsCancellationRequested)
+ if (token.IsCancellationRequested)
throw new BeatmapLoadTimeoutException(BeatmapInfo);
mod.ApplyToBeatmap(converted);
@@ -119,7 +120,7 @@ namespace osu.Game.Beatmaps
{
foreach (var mod in mods.OfType())
{
- if (cancellationToken.IsCancellationRequested)
+ if (token.IsCancellationRequested)
throw new BeatmapLoadTimeoutException(BeatmapInfo);
mod.ApplyToDifficulty(converted.Difficulty);
@@ -138,10 +139,10 @@ namespace osu.Game.Beatmaps
{
foreach (var obj in converted.HitObjects)
{
- if (cancellationToken.IsCancellationRequested)
+ if (token.IsCancellationRequested)
throw new BeatmapLoadTimeoutException(BeatmapInfo);
- obj.ApplyDefaults(converted.ControlPointInfo, converted.Difficulty, cancellationToken);
+ obj.ApplyDefaults(converted.ControlPointInfo, converted.Difficulty, token);
}
}
catch (OperationCanceledException)
@@ -153,7 +154,7 @@ namespace osu.Game.Beatmaps
{
foreach (var obj in converted.HitObjects)
{
- if (cancellationToken.IsCancellationRequested)
+ if (token.IsCancellationRequested)
throw new BeatmapLoadTimeoutException(BeatmapInfo);
mod.ApplyToHitObject(obj);
@@ -164,7 +165,7 @@ namespace osu.Game.Beatmaps
foreach (var mod in mods.OfType())
{
- cancellationToken.ThrowIfCancellationRequested();
+ token.ThrowIfCancellationRequested();
mod.ApplyToBeatmap(converted);
}
diff --git a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs
index 6e679279a4..2f46682b1a 100644
--- a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs
+++ b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs
@@ -216,7 +216,7 @@ namespace osu.Game.Screens.Play.HUD
this.gameplayBeatmap = gameplayBeatmap;
}
- public override IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList mods = null, CancellationToken cancellationToken = default)
+ public override IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList mods = null, CancellationToken? cancellationToken = null)
=> gameplayBeatmap;
protected override IBeatmap GetBeatmap() => gameplayBeatmap;