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

"Initialization" scenes (_change_scene lag spike) #38

Closed
TinyTakinTeller opened this issue Jan 15, 2025 · 3 comments
Closed

"Initialization" scenes (_change_scene lag spike) #38

TinyTakinTeller opened this issue Jan 15, 2025 · 3 comments

Comments

@TinyTakinTeller
Copy link

TinyTakinTeller commented Jan 15, 2025

EDIT 2:

Seems related to this: https://www.reddit.com/r/godot/comments/17rlyl3/two_scene_loader_issues_global_freeze_for_some/


EDIT 1:

After some investigation, I noticed that _change_scene can be slow (couple seconds slow) which freezes the transition after fading out and before fading in again, for those couple seconds.

(It was not the _ready of the "initialization" scene that was causing the extra wait time in the transition.)

Not sure what is the best way to mitigate this and have "smooth" transitions?

(Can we avoid freeze when adding large scene to scene tree?)


Initialization scenes

Some scenes need time to process their _ready method. This is given in the "More Complex Example With Loading Screen for Scenarios That Scenes Need Some Time in Background" example.

But should this be a part of the scene manager (as a default case)? - Say you can set a flag "initialization = true" which would mean that after loading the scene to 100, the scene manager would first add it to scene tree and wait for the ready method to finish, and only then emit load_percent_changed at 100 and load_finished signals.

In most cases, you do not need granular percent changes in loading bar. - Should be sufficient to keep it at 99 until _ready is finished as it takes just a second or two in most cases.

@TinyTakinTeller TinyTakinTeller changed the title "Initialization" scenes "Initialization" scenes (_change_scene slow?) Jan 15, 2025
@TinyTakinTeller TinyTakinTeller changed the title "Initialization" scenes (_change_scene slow?) "Initialization" scenes (_change_scene lag spike) Jan 15, 2025
@maktoobgar
Copy link
Owner

Hi,

About the Initialization scenes segment:
We already have a scene_changed signal and we can have another signal called scene_ready which fires when _ready of the new scene is called and this should fix if any problem is occurring because of that. Plus I do believe we can not keep the percentage to 99% because the programmer has to initiate the changing scene process and if the percentage is frozen at 99%, programmer never changes the scene and... Yeap... I don't think this bit is possible.

About the second part:

After some investigation, I noticed that _change_scene can be slow (couple seconds slow) which freezes the transition after fading out and before fading in again, for those couple seconds.

Can you please provide a video of the freeze happening? This is a little bit hard for me to understand exactly how the freeze is noticeable when we just have a black (or whatever color) on the foreground.

(Can we avoid freeze when adding large scene to scene tree?)

I'm afraid if the problem is engine related, I'm not gonna be too helpful.

This is not good news...

@TinyTakinTeller
Copy link
Author

TinyTakinTeller commented Jan 16, 2025

Yeah, looks like this is tightly related to the engine itself... ⚰

Thanks for the reply.

(Yes, the black or whatever color lasts longer than expected - this is the "freezing".)


Seems the best workaround for now (for those scenes where it is important to not have this delay) would be to... - Have those scenes loaded together once in a common parent and then toggle their visibility and process mode from on to off (and vice versa), to do the "switching" but without modifying the scene tree (no additions nor deletions when "switching").

@TinyTakinTeller
Copy link
Author

I'll close it as this is purely Godot issue it seems.

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

No branches or pull requests

2 participants