Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.InvalidCastException: Unable to cast object of type 'osu.Game.Rulesets.Taiko.Beatmaps.TaikoBeatmap' to type 'osu.Game.R... #25663

Closed
ppy-sentryintegration bot opened this issue Dec 4, 2023 · 2 comments · Fixed by #25665 or #25691
Assignees
Labels
area:skin-editor priority:0 Showstopper. Critical to the next release. type:reliability

Comments

@ppy-sentryintegration
Copy link

Sentry Issue: OSU-TRW

System.InvalidCastException: Unable to cast object of type 'osu.Game.Rulesets.Taiko.Beatmaps.TaikoBeatmap' to type 'osu.Game.Rulesets.Osu.Beatmaps.OsuBeatmap'.
  ?, in OsuBeatmap OsuAutoGenerator.get_Beatmap()
  ?, in new OsuAutoGenerator(IBeatmap beatmap, IReadOnlyList<Mod> mods)
  ?, in ModReplayData OsuModAutoplay.CreateReplayData(IBeatmap beatmap, IReadOnlyList<Mod> mods)
  ?, in Score ModExtensions.CreateScoreFromReplayData(ICreateReplayData mod, IBeatmap beatmap, IReadOnlyList<Mod> mods)
  ?, in Score <>c__DisplayClass36_0.<PresentGameplay>b__1(?)+(IBeatmap beatmap, IReadOnlyList<Mod> mods) => { }
...
(16 additional frame(s) were not displayed)

An unhandled error has occurred.
@peppy peppy added priority:0 Showstopper. Critical to the next release. type:reliability labels Dec 4, 2023
@bdach bdach self-assigned this Dec 4, 2023
@bdach
Copy link
Collaborator

bdach commented Dec 4, 2023

Reproduction: open skin editor at main menu when a track for a mapset is playing that cannot be converted to the current ruleset (example: open skin editor with mania set track playing and osu! ruleset active)

@bdach
Copy link
Collaborator

bdach commented Dec 6, 2023

Can still replicate this.

@bdach bdach reopened this Dec 6, 2023
bdach added a commit to bdach/osu that referenced this issue Dec 6, 2023
…main menu

Closes ppy#25663 (again).

As it turns out, in some scenarios it can be the case that the current
game-global `Beatmap` is not valid for the current game-global
`Ruleset`. The validity of one and the other in conjunction is only
really validated by the song select screen; elsewhere there is no
guarantee that the global beatmap is playable using the global ruleset.

However, this only comes up in very specific circumstances, namely one:
when trying to autoplay a catch beatmap with osu! ruleset globally
active via the skin editor flow.

`Player` is responsible for retrieving the beatmap to be played. It does
so by invoking the appropriate beatmap converter and asking it if the
beatmap can be converted:

	https://github.com/ppy/osu/blob/6d64538d7a3130df63574eb75a8ebe044154c799/osu.Game/Beatmaps/WorkingBeatmap.cs#L262-L266

If the code above throws, `Player` actually silently covers for this, by
trying the beatmap's default ruleset instead:

	https://github.com/ppy/osu/blob/6d64538d7a3130df63574eb75a8ebe044154c799/osu.Game/Screens/Play/Player.cs#L529-L536

However, for the pairing of osu! ruleset and catch beatmap, this fails,
as `OsuBeatmapConverter`'s condition necessary for permitting conversion
is that the objects have a defined position:

	https://github.com/ppy/osu/blob/6d64538d7a3130df63574eb75a8ebe044154c799/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs#L25

which they will do, due to the fact that all catch beatmaps are really
just osu! beatmaps but with conversion steps applied, and thus `Player`
succeeds to load the catch beatmap in osu! ruleset.

In the skin editor scenario, this would lead to the secondary failure
of the skin editor trying to apply `CatchModAutoplay` on top of all
of that, which would fail at the hard-cast of the beatmap
to `CatchBeatmap`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:skin-editor priority:0 Showstopper. Critical to the next release. type:reliability
Projects
None yet
2 participants