Description
Describe the project you are working on
Any Godot project.
Describe the problem or limitation you are having in your project
UID caching was introduced with Godot 4.0, and along with it came a number of bugs (these are what are opened as of today, this doesn't include the fixed bugs)
godotengine/godot#62258
godotengine/godot#64330 (related to 68661)
godotengine/godot#67851 (related to 68661)
godotengine/godot#68661
godotengine/godot#68672 (related to 62258)
#7181
I've also ran into issues with UIDs, and considering I don't require its features I've consider disabling them locally. I'm worried about future Godot features that absolutely require UIDs, as well as other unintended side effects.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add a project setting called application/config/enable_uid_cache (or application/config/enable_uids) to enable (default) or disable UIDs and UID caching (uid_cache.bin), plus a description for the pros and cons of doing so.
Pros:
- Reduce noise in git since UIDs won't change in scene or resource files, since there are none.
- Can be used as a workaround for bugs that a user cannot otherwise workaround, like for the bugs listed earlier.
- Reduces one point of confusion when incorrect scenes or resources are loaded, especially for new users.
- Saves some space in the final exported project, granted it's not much (usually <100KB; highly dependent on the project).
Cons:
- Moving a file can break other scenes/resources outside of the editor.
- Existing code that loads UIDs explicitly, like with
load("uid://someuid")will break. - 3rd party addons that load UIDs explicitly will also break.
This appears as though Godot would now have to support "UIDs" and "no UID"s, however the code already does this for the most part by checking for ResourceID::INVALID_ID and falling back to paths (or doing nothing, depending on the context).
I've been hesitant on this proposal because I'm pretty sure it's going to be rejected only because UIDs were added to solve the problems (the Cons) above, and could only cause even more confusion (like if a user has UIDs disabled, then adds an addon that uses UIDs and sees it not working).
Though I want to open some discussion on it considering how low-impact the underlying change is, and how easy it is for a user to just switch back to UIDs (by re-enabling this option).
Possible alternative:
A hybrid approach could mitigate some of the Cons (2 and 3) by using existing UIDs, but not generate new UIDs for new scenes/etc. This can be thought of as "locking in" existing UIDs. Empty projects that set this setting will not have UIDs assigned to anything. However if they include an addon that uses UIDs then the addon will still function normally since UID lookup will still work correctly.
This could be considered even more confusing from a user perspective though.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Below describes the original idea, not the hybrid approach.
- At initialization in main.cpp, choose either
ResourceUIDor a new class that derives fromResourceUID(ResourceUIDDummyorResourceUIDStub) based on whetherapplication/config/enable_uid_cacheis true or false. ResourceUIDDummydeletesuid_cache.bin, and always returnsResourceID::INVALID_ID, empty strings,Error::OK, etc.- So when
ResourceUIDDummyis in use, scenes and resources are saved and loaded similar to pre 4.0, as in, based on path rather than UID. There is no longer a UID stored in the scene (tscn) or resource (.import). - UIDs in existing scenes or resources are ignored when loaded, however saving those scenes or resources will erase the UID.
- Keep UIDs and UID caching enabled by default since many projects are currently (and usually unknowingly) using them, as well as not break projects that explicitly use them (like
load("uid://something")).
I have a potential (and very lightly tested, unsubmitted) PR that implements this.
If this enhancement will not be used often, can it be worked around with a few lines of script?
No, this is part of the core.
Is there a reason why this should be core and not an add-on in the asset library?
ResourceUID must be modified, which cannot be done with an addon.