Skip to content

Fix StructuralSparseArray Clear function and add basic test #273

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

Merged
merged 1 commit into from
May 9, 2025

Conversation

LilithSilver
Copy link
Contributor

@LilithSilver LilithSilver commented May 9, 2025

Currently, StructuralSparseArray is broken quite badly since the Clear() method doesn't empty the whole array.

Because of this, using Add and Remove in a reused CommandBuffer can occasionally corrupt the state of the world, by adding a component twice on an entity! The CommandBuffer needs to be recreated from scratch every time, because the StructuralSparseArray does not clear correctly.

This PR fixes the bug and adds a basic functionality test, testing operations against a control HashSet. The test currently fails on master, but passes after this PR.

I can't figure out how to reproduce the CommandBuffer bug for a unit test -- it only occurs in the wild after a very specific sequence of Add and Remove operations and playbacks, that I have yet to understand. But this fixes the root of the issue, regardless.

@LilithSilver
Copy link
Contributor Author

Oh whoops.... This is a duplicate of #273, that's my bad. Keeping it open since mine adds a unit test, but the other code is slightly better.

@genaray genaray merged commit 439bd13 into genaray:master May 9, 2025
8 checks passed
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

Successfully merging this pull request may close these issues.

2 participants