-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix for threaded NavigationMesh baking under new thread guards #77412
Fix for threaded NavigationMesh baking under new thread guards #77412
Conversation
0fe5f2a
to
cbc9b6d
Compare
Fixes threaded NavigationMesh baking under new SceneTree thread guards that blocked the process.
cbc9b6d
to
ee14b01
Compare
CC @RandomShaper to review the threading assumptions. |
The scene tree was already non-thread-safe. That means that if the baking process was already playing safely with it (knowing what it is doing), it's just a matter of disabling the thread guards for the baking thread. However, I have the impression that this PR acknowledges that it wasn't safe earlier either and brings in a new, perfectly safe approach. Is that right? Regarding guards, since the generic thread guards are still in the scope of |
@RandomShaper This pr not only acknowledges all that but splits the navigation mesh baking steps between the must-be-main-thread geometry parsing part and the can-be-background-thread navigation mesh baking part. When I made this issue / pr the "exception options" for the thread guards were not a thing and it wouldn't solve the core issues and crashes anyway for the geometry parsing. One part of me is actually glad that the SceneTree and thread changes now forces a hard reset for how Godot does navigation mesh baking. The old implementation never really was designed or worked for threads but no one had time or wanted to change the status quo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll go ahead and take the liberty to give an approval based on the excellent rationale on threading. Regarding navigation itself, I can't really give an informed opinion, but can't spot anything fishy.
Thanks! |
Fixes threaded NavigationMesh baking under new SceneTree thread guards that blocked the process.
Fixes #77180.
As mentioned in the linked issue. The new SceneTree thread guards created the sudden problem that the navigation mesh baking could no longer parse the SceneTree for nodes when running on a thread, which is the default. Now, that the SceneTree is not thread-safe is not something that will change in the near future but single-threaded navmesh baking is also not really an option.
To solve this the bake functionality is now split between the SceneTree parsing step (not thread-safe) and the navigation mesh baking step (thread-safe).
This pr also ports a few fixes and smaller features like the
NavigationMeshSourceGeometryData
from pr #70724. The NavigationMeshSourceGeometryData adds the option to reuse already parsed source geometry or to add it procedurally. This can help to mitigate performance loss that could be caused by the now forced main thread parsing. To quote the description from the rework pr.Since the NavigationMeshGenerator singleton has a problematic dependency and init chain in current Godot new functions were added to both the NavigationMeshGenerator and The NavigationServer3D (not bound for scripting). Expect them to change / disappear again when the dependency issues are resolved and / or the larger rework prs merged.
Parsing Performance Tips:
With the source geometry parsing now enforced on the main thread problems may show up for projects with heavy scenes and nodes but there are also some new options to solve them.