-
Notifications
You must be signed in to change notification settings - Fork 187
Labels
Milestone
Description
I think the current approach to free the data is not viable.
Right now the following happens:
On data removal, a swap remove is performed. This is achieved by reassigning the index in its source location, in the per chunk hashmap.
This however produces race conditions like this:
- ChunkMesh A gets out of render distance, so its refcount is reduced by 1, however it is still used somewhere else, so its BlockEntity data is not cleared.
- ChunkMesh B gets out of render distance, it's refcount is now 0 so its BlockEntity data is freed.
- While freeing a swapRemove happens, that swaps one of the block entities of Chunk A
- The system tries to get Chunk A using the mesh_storage, but it doesn't have the chunk anymore because it's already out of render distance
I think the simplest solution would be avoid any remapping of indices and just use a SparseSet #1414 to ensure denseness.