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
commit 812def124f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)