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

ResourceLoader.load_threaded_request blocks main thread #79117

Open
Wiggan opened this issue Jul 6, 2023 · 6 comments
Open

ResourceLoader.load_threaded_request blocks main thread #79117

Wiggan opened this issue Jul 6, 2023 · 6 comments

Comments

@Wiggan
Copy link

Wiggan commented Jul 6, 2023

Godot version

4.1

System information

Windows10, AMD Ryzen 9 5900X, NVIDIA GeForce RTX 3060 Ti, driver version 30.0.15.1179, compatibility.

Issue description

I try to show a progressbar while loading a scene in background.
_process() of the caller is called only once while loading though. It seems like the main thread is blocked.

Steps to reproduce

Start the repex and notice that it takes (for me) 3s to load the new scene, but _process is called only once with a delta of 0.016666s.

Minimal reproduction project

threaded_loading_repex.zip

@Wiggan
Copy link
Author

Wiggan commented Jul 6, 2023

I might have a clue:
I made the scene slow to load by having 5120*5120 noise textures. They are CPU-bound, not IO-bound which is maybe the normal case when loading stuff.
But running CPU-intensive stuff in a thread should still not affect the main thread, so I still consider it a bug I think.

@Calinou
Copy link
Member

Calinou commented Jul 6, 2023

Loading textures is not asynchronous yet – this requires making RenderingDevice thread-safe. You'll probably want support for texture streaming as well, which is planned for a future release.

@djrain
Copy link

djrain commented Sep 7, 2023

So there's literally no way to load textures without stalling main thread? That's a bummer. Any idea when this will be addressed?

@Calinou
Copy link
Member

Calinou commented Sep 9, 2023

So there's literally no way to load textures without stalling main thread? That's a bummer. Any idea when this will be addressed?

Rendering contributors are busy with other tasks, so it will be a while before texture streaming is implemented. (Also, texture streaming will only be supported for rendering in 3D, not 2D.)

@djrain
Copy link

djrain commented Sep 10, 2023

it will be a while before texture streaming is implemented

Sure, I meant to ask about the asynchronous loading. We designed our 2D game's overworld to be "seamless", but I guess for now we are stuck with some stutters (there are too many textures to preload)

@Calinou
Copy link
Member

Calinou commented Sep 10, 2023

We designed our 2D game's overworld to be "seamless", but I guess for now we are stuck with some stutters (there are too many textures to preload)

You can stagger texture loading over time, and split large textures into several smaller textures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants