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

When using SwitchWithTransition for participating scenes Load and Unload are called twice #4

Closed
karolmajta opened this issue Dec 13, 2023 · 2 comments · Fixed by #6
Closed
Milestone

Comments

@karolmajta
Copy link

It can be easily reproduced by creating two scenes, the first one just transitions to second one. I'm not posting the snippet (for brevity), but it's easy enough to reproduce. There are logs which look like:

2023/12/13 17:55:53 Load Main Scene
2023/12/13 17:55:53 SwitchWithTransition called...
2023/12/13 17:55:53 Unload Main Scene <----------------- why would we unload the scene here? it still needs to be drawing
2023/12/13 17:55:53 Load Jump Scene <------------------ this is ok
2023/12/13 17:55:53 Draw in Main
2023/12/13 17:55:53 Draw in Jump
2023/12/13 17:55:53 Draw in Main
2023/12/13 17:55:53 Draw in Jump
...
2023/12/13 17:55:54 Draw in Jump
2023/12/13 17:55:54 Draw in Main
2023/12/13 17:55:54 Draw in Jump
2023/12/13 17:55:54 Unload Main Scene <---------------- this is expected here, scene is gone after transition so unload it
2023/12/13 17:55:54 Load Jump Scene <---------------- this scene's `Load` gets called second time
2023/12/13 17:55:54 Draw in Jump
2023/12/13 17:55:54 Draw in Jump
2023/12/13 17:55:54 Draw in Jump
...
^Csignal: interrupt

Question is - is this on purpose? If yes, I could live with that, but it seems a bit puzzling tbh.

@karolmajta
Copy link
Author

I have a fix for this behavior, but I'd like to know if this is intentional. If yes, I'll just let it be.

@joelschutz
Copy link
Owner

This is really a bug that I left as a feature. At first I couldn't figure out how to solve it(since the new scene needs to be loaded with the previous state anyway), but found useful to have this double call to know where the transition start and end.

But you can make a suggestion and we can figure a way that is more explicit and compatible. The main thing that bothers me in this system is that the scene has no way to know if it's a transition or not. My first idea was to have a pre-transition(on old scene to extract the state) and post-transiton(on new scene to confirm complete load). But I didn't figured how it should work on a simple transition.

I'm on vacation now and can start to investigate a bit, feel free to help in the discussion or in a PR.

@joelschutz joelschutz linked a pull request Mar 1, 2024 that will close this issue
3 tasks
@joelschutz joelschutz mentioned this issue Mar 2, 2024
3 tasks
@joelschutz joelschutz added this to the v1.1 milestone Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants