maktoobgar/scene_manager

consideration for stack size for newer versions after 2.0.1

mrwormhole opened this issue · 4 comments

hello, I have been using scene manager 2.0.1 for Godot 3.x game that will make it to android game market as a puzzle. I have read all the work that you have put into this, I must say I was amazed by this addon. (it is the best tool out there in godot plugin market)

one thing I realized is, the stack size keeps growing unless I reset the scene, in later versions of 2.0.1, have you considered adding a stack cleaning/pruning default limit? like 50-100 default and after that many transitions, the stack does remove on the [0] element like a buffer size.

Hello,
Thanks for your kind words. I'm happy that this addon is actually useful and been used in a practical project that will be released to public.
I'm actually trying to improve it and add more features for godot4 at the time and support load screens in future releases too. (not too soon but I wish it happens sooner)

About the question, If I want to be honest, not really.
Is there a need for it?
I mean in terms of space allocation, _stack is just an array of strings. Even if it goes high up to 50-100 or even 10000 elements(which is a super rare condition), it doesn't really take a lot of space.
Plus if I add this behavior and programmer doesn't know or doesn't want it, like you said, after 50-100 reset is gonna automatically happen anyway and that's gonna cause the programmer some confusion or unwanted behavior.
I get that it's a rare condition but... My image of scene_manager is that I got to give all handles to programmer's hand and avoid side effects that programmer does not know about them or cause unwanted behavior.
So that's why I don't see this behavior needed.
What is your vision in this exactly?
Why this is needed?
Does it cause performance problems in your project or...?

my assumption was if someone holds the app on pause and doesn't close it forever, it can go over limits, I do agree with side effect side because all the other scene managers have too many side effects, it should be very visible and obvious to the user like putting stack max size to here on the menu and making it overrideable. It doesn't cause a performance problem, it may cause a memory overflow if the player keeps the app running in the background all the time.

image

I don't think after 1000 stacks, the user will want to go back to the first stack frame with back button, that was the reason of my thinking

I can make it a feature and by calling a function like set_stack_limit(input: int) -> void, there can be a limit which the programmer can set for _stack variable.
And input in the function can have three different values:

  1. input = -1 which means no limit. (by default)
  2. input = 0 which means do not stack scenes at all.
  3. input > 0 which means a limit for _stack and let's not have a reset functionality on this but instead I think this is a better functionality to have the limit and when the limit reaches, pop one item from the end(which is an old data) and then push one in and like that, we don't have sudden loosing of our data anymore.

Is this interesting?

Added and tested it all, but the function name is set_back_limit instead of set_stack_limit and works exactly as I mentioned in previous comment and inside README.md.

For godot3:
https://github.com/maktoobgar/scene_manager/releases/tag/2.1.0

For godot4:
https://github.com/maktoobgar/scene_manager/releases/tag/3.2.0

If you had any other ideas or found any bugs, let me know.
And happy new year. 🥳