-
Notifications
You must be signed in to change notification settings - Fork 5
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
Get some lag spikes while loading ? #19
Comments
Hello @Celthim . The problem of stuttering is usually caused by shader compilation, or from blocking code. Shader compilation happens the first time something is shown on the screen. If you start the game, load the menu, unload the menu, then reload the menu does it still stutter? The second time you load it, it should not stutter, as the shaders are cached. There are a few ways to get around this:
Also note that if you use Godot 4.0, it uses Vulkan instead of OpenGL by default. Apparently Vulkan automatically compiles shaders async. So it does not suffer from this problem. I have no idea if it works yet though, as I haven't gotten it to work well enough to test. |
Thanks for your response ! I tried to change the Shader compilation mode to asynchronous, but it didn't changed. I'm not sure that shaders are the problem here as I don't have any heavy shader or anything atm. Help me understand a little bit more, you're saying that stuttering is caused by blocking code. I saw your video explaining that loading scenes is blocking code. My goal was by delegating the loading to another thread, that the main thread won't be blocked at all. Is this a misunderstanding from me ? To detail what happens : What you see on the capture is a menu that appears as a main menu (it will be more of a main menu later) So I tried to show only the menu itself, without loading anything from the main scene and there's no stuttering at all. Wich would mean that I would have to decompose the whole main scene bit by bit and load everything using the plugin ? I'm currently on Godot 3.5, I'm using Spine wich wait for a stable release to gets any upgrade Thanks ! Edit : I talked to the community on the Godot discord. I got the confirmation that loading it shouldn't block the main thread. However the main lead of what's happening is that adding scenes to the tree is also a blocking operation that Godot don't thread cause it's considered unsafe if I understood well. I'll try maybe to add the scene to the tree at the last moment, delaying the lag spike to when the player clicks on the button. If that doesn't work, the alternative solution would be to decompose my main scene into chunks to be loaded bit by bit but as I said earlier it complicate all the signals connexions and variable access so that would be in last resort. If you have other leads or anything else to add I'm all ears ! |
Sorry I didn't comment earlier. I'm having some terrible real world stuff happening, and didn't have time to read this. It is hard to figure out what is causing the stuttering problem, without seeing the code. Adding things to the scene tree does indeed block the main thread. I've never used Spine, so I'm not sure how that plays into things. Let me know if you have any luck with getting it to work. |
Hi !
I searched for a plugin like yours because having my scene loading at start makes my game a bit long to load so I wanted to delay some loading while the player is in the menus.
I managed to get the plugin to work even if I'm in 2D, but for some reasons I still get little lag spikes when it loads.
I don't know exactly what could cause this,
Here is basically the code I'm using (I removed all "position" related args everywhere as I don't need them and it was not compatible with 2D)
Init :
async calls :
Callback :
AsyncLoadLagSpike.mp4
The text was updated successfully, but these errors were encountered: