-
-
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
Prevent threading problems in TileMap
#87478
Prevent threading problems in TileMap
#87478
Conversation
Due to the various effects of this I'm not marking it for cherry-picking and keeping #87470 as the main fix for the editor crashes I'd say the possible drawbacks of not being able to have the map update when not in the tree are worth the thread safety improvements (without having to make the whole class thread safe), the main problem is that even when not in the tree it isn't thread safe as the update is deferred and can collide with threaded processing, especially when adding a lot of tiles for example adding a pattern |
69fa964
to
c198248
Compare
Reverted the changes from #87470 for this as they are no longer needed if this works, and it just takes up some performance and memory, but as that fix is cherry-pickable and I don't feel confident cherry-picking this one at least not without extensive testing, and it does change behavior It also makes it easier to test this as it can be tested in the editor with #86226, though general thread safety should be ensured here To clarify though: |
Not fully ready by a bit yet but marking ready for review to get some eyes on it, still needs some testing and cleaning up and decisions This changes behavior in cases where it is already thread safe, i.e. when modified from the main thread, when not in the scene tree In these cases, where, for example, you update a tile map incrementally but on the main thread, outside of the scene tree, the updated internals won't be available even if you do it, for example, in I'm not feeling confident that this change won't cause confusion in these specific cases, or in "partially" thread safe use, i.e. when you're lucky and it doesn't crash (which is largely the case when you don't do large batch updates), as you now have to explicitly call But I'm not familiar enough with all the details to know what if any of that data is relevant outside of the tree, if it isn't I'd say to also cherry pick this one |
c198248
to
23ed363
Compare
This comment was marked as outdated.
This comment was marked as outdated.
23ed363
to
1d0606c
Compare
TileMap
TileMap
2d77408
to
c66faea
Compare
CC @groud |
c66faea
to
7242581
Compare
7242581
to
fe203d7
Compare
There, removed the additional note in the documentation, cleaned up the comments, and added a comment to the blocked update |
This comment was marked as outdated.
This comment was marked as outdated.
Thanks! |
Thank you! |
Hey. Was just testing this one out from Godot 4.3 Dev 4 build and it didn't seem to solve the issue i have regarding instantiating big Tilemaps on separate thread. #87402 Loading the resource works as it always has on a separate Thread, but not instantiating it. I still get the logs spammed with this message: From what i saw, this PR is in the Dev 4 build. |
Left a comment on that issue, I'm not sure it's entirely a bug as resources are not thread safe, but worth investigating, unsure what's causing it in this case, but the stack trace isn't for the tile map |
Still needing to rework the places this is used and do some deeper testing but just to do some testing with this base and for some input
Will also update documentation etc. to clarify that it doesn't update automatically when not in the tree but that manual updates are required
Follow-up/related to (which it reverts on
master
as its no longer needed):TileMap
preview #87470See also:
Note: This does not make
TileMap
thread safe, like all nodes they aren't safe to manipulate from multiple threads, or from a thread when in the scene treeWhat it does is make it possible to use it in a thread safe fashion, by preventing it from being manipulated on the main thread due to deferred updates