osu-framework icon indicating copy to clipboard operation
osu-framework copied to clipboard

Pushing a screen at OnExiting without blocking the exit freezes the UI

Open mcendu opened this issue 5 years ago • 3 comments

Per title. The following test if put in TestSceneScreenStack triggers it. I am not sure what is the intended behavior here.

        [Test]
        public void TestPushOnExitingWithoutBlocking()
        {
            TestScreen screen1 = null;

            pushAndEnsureCurrent(() =>
            {
                screen1 = new TestScreen(id: 1);
                screen1.Exiting = () =>
                {
                    screen1.Push(new TestScreen(id: 2));
                    return false;
                };
                return screen1;
            });

            AddStep("Exit screen 1", () => screen1.Exit());
        }

mcendu avatar Jul 05 '20 04:07 mcendu

It's undefined behaviour (you're pushing a new screen to a screen that you've implied to be exited).

So let me ask you then: what do you expect in this scenario? what are you trying to make happen here? the new screen pushed to the parent in the stack?

peppy avatar Jul 05 '20 04:07 peppy

This shouldn't be closed (it does need a resolution, even if that is just throwing an exception). Could you answer my question to help us decide how this behaves or offer an alternative?

peppy avatar Jul 05 '20 05:07 peppy

I think it is good to throw an exception here (maybe ScreenNotCurrentException); nobody is going to expect such a thing to happen IMO.

mcendu avatar Jul 05 '20 05:07 mcendu