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 TileMapLayer bug where dirty cells could be marked twice #102688

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

caleb98
Copy link
Contributor

@caleb98 caleb98 commented Feb 11, 2025

Summary

Adds additional checks to TileMapLayer::_build_runtime_update_tile_data_for_cell to ensure that dirty cells have not already been added to the dirty cells list before calling dirty.cell_list.add(...). Previously, updating a cell and calling notify_runtime_tile_data_update in the same frame or through coroutines could cause ordering issues here resulting in a large number of error messages being printed.

Using the MRC provided in the linked issue, I verified that the errors are no longer being printed, and calling notify_runtime_tile_data_update using call_deferred is no longer necessary

I'm also attaching an MRC to this PR for the case where messages can still be printed when using call_deferred if coroutines are involved. Adding these additional checks prevent the error messages in this MRC as well: Coroutine MRC

When using runtime data in a TileMapLayer, calling notify_runtime_tile_update
can cause error messages to be printed to the console if the same cell has been
set or erased in the same frame. This could be partially worked around by using
call_deferred on notify_runtime_tile_update, but the problem could re-emerge if
those updates were being made in coroutines.

This commit addresses the issue by adding an additional check to the dirty cell
marking of the TileMapLayer when notify_runtime_tile_update is called. This
check ensures that the cell has not already been added to the dirty cell list,
preventing the condition that causes the error message.
@caleb98 caleb98 requested a review from a team as a code owner February 11, 2025 04:07
@Chaosus Chaosus added this to the 4.4 milestone Feb 11, 2025
@akien-mga akien-mga added the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Feb 11, 2025
@akien-mga akien-mga merged commit 65b8164 into godotengine:master Feb 11, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release topic:2d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error [ Condition "p_elem->_root" is true. ] spamming the console
4 participants