1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-26 02:29:54 +08:00

Merge pull request #23661 from peppy/fix-multiplayer-present-crash

Fix `OnResume` / `OnSuspending` potentially getting called before `OnEntering` on a sub screen
This commit is contained in:
Dean Herbert
2023-05-31 19:43:30 +09:00
committed by GitHub
Unverified
@@ -132,7 +132,12 @@ namespace osu.Game.Screens.OnlinePlay
this.ScaleTo(1, 250, Easing.OutSine);
Debug.Assert(screenStack.CurrentScreen != null);
screenStack.CurrentScreen.OnResuming(e);
// if a subscreen was pushed to the nested stack while the stack was not present, this path will proxy `OnResuming()`
// to the subscreen before `OnEntering()` can even be called for the subscreen, breaking ordering expectations.
// to work around this, do not proxy resume to screens that haven't loaded yet.
if ((screenStack.CurrentScreen as Drawable)?.IsLoaded == true)
screenStack.CurrentScreen.OnResuming(e);
base.OnResuming(e);
}
@@ -143,7 +148,12 @@ namespace osu.Game.Screens.OnlinePlay
this.FadeOut(250);
Debug.Assert(screenStack.CurrentScreen != null);
screenStack.CurrentScreen.OnSuspending(e);
// if a subscreen was pushed to the nested stack while the stack was not present, this path will proxy `OnSuspending()`
// to the subscreen before `OnEntering()` can even be called for the subscreen, breaking ordering expectations.
// to work around this, do not proxy suspend to screens that haven't loaded yet.
if ((screenStack.CurrentScreen as Drawable)?.IsLoaded == true)
screenStack.CurrentScreen.OnSuspending(e);
}
public override bool OnExiting(ScreenExitEvent e)