-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Saving with instanced scenes is nondeterministic. #30538
Comments
I can confirm this, it's a real pain (and I think it's a regression, it used to be more reliable in the past, though there were other issues with tscn determinism). There's an existing issue about this but I'm on phone now, can't check for the number. Might make sense to keep this one open and focused on a potential regression in handling tscn instances, it's the first time I see it mentioned as being the potential culprit. |
We could just alphabetically sort by path name on save? |
Seems as if the consistent resource IDs were implemented in commit c1dcdf6 , however given its current buggyness, I'd move to get rid of this caching code and sort each category of resources alphebetically on resource saving regardless of whether or not the editor tools are in the current binary. |
After removing the changes made in c1dcdf6 that have to do with path caching, resources are saved in the order that they are in the editor. Is this acceptable behavior? |
Storing in alphabetically would be more consistent in my opinion. |
Note that when you say alphabetical, you mean lexigraphical (ascii / utf8 ordering) and not actual alphabetical order which requires per language lookup tables right? |
Whichever is simpler and faster is better, as long the order is reproducible with as less extra/unrelated/useless data as possible. |
Lexicographically, as the |
I've implemented a lexicographical sorted external scene saving and opened a PR to have it merged. It makes the external resource listings stay the same no matter the order of the nodes in the scene tree, however, it's worth noting that rearranging the nodes still produces a different scene file as the |
That should be fine since rearranging nodes is a change that is relevant. |
I'm not a fan of lexicographical sorting because it has the potential of creating large diffs at the introduction of a single new resource. By introducing a value that sorts earlier than others, you'll shift all the other indices and cause diffs on nodes that didn't actually change in any way as they need to update the references. What's really needed is a consistent hash so then ordering doesn't matter. |
I'm in the process of fixing the actual bug right now @nhydock . The IDs are cached in the resource, but because the resource is a reference, I believe that at the end of the |
It seems as if resources are being freed, and so the path cache is being lost on scene startup and also the mesh-instances on closing the scene. |
- PackedScenes freed before saved, so their path cache is lost - Solution is to move data to persistent static map - This patch will fix godotengine#30538
Not only the order, but sometimes a root node in a TSCN scene has an attribute |
Index=0 is a separate issue that should've been fixed already. |
@Zylann I can confirm that the issue is reappearing in a different form in 3.2 alpha 3, it seems to consistently happen with only two packed scenes on every save, however I am not seeing the meta tags reappear in this version. ( in the provided image, only those two packed scenes have been switching back and forth nondeterministically every save ) |
This seems to have gotten REALLY bad recently. I've been doing custom builds, so I'm not sure exactly which version has the issue, but my previous 3.x sync was before the beginning of the year and I just recently synced a few weeks ago, so probably around 3.5, and now, if I so much as LOOK at a scene, 90+% of my id's get randomly shuffled: Makes it extremely difficult to tell what, if anything, actually changed. I thought maybe something just changed with the sorting order and once files had been updated to the new version, they'd be consistent, but every time I go to check in, files are changed. Basically any scene I have open, even if I don't touch it, gets randomly shuffled. |
If this still happens why not re-open it? Or should I open a separate issue? |
You should open a new issue. Similar general description of symptoms 3 years later != same bug. |
Godot version:
Master, built from 0b69be9
OS/device including version:
Windows
Issue description:
When saving, the order in which external scenes are loaded and thus their index can randomly change. Other external resources seem fine.
To be clear, I am talking about these lines in a .tscn-file:
The order of such lines can change and thus the index/id will differ.
While this bug does not cause the scene to break, it generates a lot of clutter for version control.
Steps to reproduce:
Minimal reproduction project:
nondeterminism.zip
The main scene is
Test.tscn
. It consists of 10 MeshInstances usingmesh1.tres
throughmesh10.tres
. These external resources seem fine. It additionally contains instances ofsub1.tscn
throughsub10.tscn
. These resources get shuffled.The text was updated successfully, but these errors were encountered: