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

Fix thread-use causing navigation polygon data corruption #93426

Merged
merged 1 commit into from
Jun 22, 2024

Conversation

smix8
Copy link
Contributor

@smix8 smix8 commented Jun 21, 2024

Fixes navigation polygon data corruption caused by thread-use that changed vertices or polygons while the navigation polygon was processed, e.g. by server region sync, navmesh baking or user thread updates.

  • Adds NavigationPolygon RW locks to make data thread-safe where relevant.
  • Adds NavigationMesh C++ functions to set_data() and get_data() in one call to avoid desync.
  • Updates navigation mesh generator baking to use the new, more thread-safe functions.

Trio with #93392 and #93407

The NavigationPolygon has the same problematic legacy API as the NavigationMesh where it is possible to set vertices and polygon indices that are not in sync due to both using different functions with no real validation.

When user-threads were manipulating the resource there was opportunity to read the resource while another thread changed the data in the middle. This was very common in large projects when users would reuse the same navigation mesh resource and started the next update as soon as they set the navigation mesh on a region, not knowing that it takes some time for the sync to happen.

@smix8 smix8 added this to the 4.x milestone Jun 21, 2024
@smix8 smix8 requested review from RandomShaper and a team June 21, 2024 10:56
Fixes navigation polygon  data corruption caused by thread-use that changed vertices or polygons while the navigation polygon was processed, e.g. by server region sync, navmesh baking or user thread updates.
@smix8 smix8 force-pushed the poly_good_locking branch from d09ce0d to eba3aca Compare June 21, 2024 10:58
@akien-mga akien-mga modified the milestones: 4.x, 4.3 Jun 21, 2024
@akien-mga akien-mga merged commit 022b5a1 into godotengine:master Jun 22, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@smix8 smix8 deleted the poly_good_locking branch June 25, 2024 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants