-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Defer clearing of ResourceUID cache #67128
Defer clearing of ResourceUID cache #67128
Conversation
Just tested this change on my game and it seems the issue described in #64881 is still happening for my game: The .tscn files containing the uid:// strings were already pre-existing so perhaps due to this bug some of the resource ids were created wrongly and are now permanently broken. The only way to fix it currently is to manually edit every single .tscn file and remove the broken uid:// bits from there to get rid of these warnings. |
You can actually fix this without opening the scenes (manually). Just run this script in your project: @tool
extends EditorScript
var files: Array[String]
func _run() -> void:
files = []
add_files("res://")
for file in files:
print(file)
var res = load(file)
ResourceSaver.save(res)
func add_files(dir: String):
for file in DirAccess.get_files_at(dir):
if file.get_extension() == "tscn" or file.get_extension() == "tres":
files.append(dir.path_join(file))
for dr in DirAccess.get_directories_at(dir):
add_files(dir.path_join(dr)) It will open and re-save all text resource files, to make sure they are up to date. It fixes formatting, uids, old classes etc. |
@KoBeWi nope - running that makes it even worse on restart: https://gist.github.com/bitbrain/d3870f0c52cfdb20038a0066a1251a5a I also attempted to delete the .godot folder and remove all *.import files and re-import but same issue. The game works fine and resources load as expected, it's just that it still spams when opening the project. Perhaps somebody else can reproduce this on this branch? |
Are the UIDs correct though? Compare the ext resources in scenes with their actual ids; maybe it's a different issue. |
@KoBeWi example when loading my game project:
Looking into
However, this id is present within
|
Ok I checked again and the warnings seem to still appear. The PR fixes the warning before editor load, but there seem to be more warnings after it's loaded. Maybe caused by scan? EDIT: So either a solution would be not clearing the cache (which would make it grow infinitely, storing entries for deleted files) or add a fallback similar to #67124 EDITEDIT: No, fallback makes no sense, it's a reverse situation xd I think we could just silence the warning by verifying the UID with ResourceLoader. |
We might get away with just merging this PR (as it brings value already) but this means #64881 won't be fixed yet. |
b3ecfee
to
799a545
Compare
I added a brutal silencer for the warning. If the UID does not exist in cache, ResourceLoader will validate whether UID and path still match. @bitbrain check again if it fixes the warnings for you. The deferred call from the original fix is still needed for using UIDs in plugins (otherwise they fails, not just warn). |
No more warnings happening here! |
799a545
to
14b82c3
Compare
Thanks! |
I still have those weird warnings for a while now, using RC til the newly released RC3: I don't remember when they were displayed first, never change anything, and not tried the tool script provided by @KoBeWi, I don't know what t think about this, it doesn't looks like #64881 has been actually fixed or maybe #67124 created those warnings in the first place. Although everything looks like to work as expected despite the name of the loaded scene instead is not. |
Do you have any minimal reproduction project? Does saving the problematic scenes again fix the issue? |
No I don't and yes, saving the scenes again makes the warning no longer displayed. Thanks. |
Is the UID always the same? |
Ok I saved the tscn and reimported glb (in which I have external materials setted) files and warnings disappeared. Why do they appear? May I did something wrong? |
When were the files created? |
If I remember right I delete a plug-in from the file system (wrong move, I did it without thinking too much). I had warnings related to the missing plug-in that I managed to resolve and then this warnings appeared. But I don't know if they are related |
If you do changes to files that affect UIDs, like moving the file, renaming etc, it will cause UID mismatch. Each UID corresponds to a specific path, which is stored in a cache file. Godot updates it automatically when you manipulate the files (it even updates all usages of an UID inside scenes/resources), but if you e.g. externally duplicate or move the file, it will get detected as a new resource and cause all kinds of weird things. |
I get this warnings a lot not on the editor but on exported projects. This snippet really helped to automate "fixing" it Thanks a lot! But there are some strange things:
Am I doing something wrong, or is this normal? I don't think I edited these files externally since last export, I might have moved the images and a lot scenes/resources as I reorganized the project folder but I always do that through the editor. Sometimes I do save scenes and scripts in VScode, as I use it for git, but it's usually throwing away debug prints when reviewing changes before commit, or sometimes when I want to split some changes between commits, I commit some lines and not other from files. In the end everything gets committed, but there might be some file saving between them. Could that be it? |
@KoBeWi 's editor script worked for me on 4.1. I had to also add ".material" resources as well. Thanks |
Thanks very much. This resolved an issue that had been bothering me for a long time. |
EditorFile dock was clearing the UID cache, but it was happening before plugins, autolads etc. are loaded, resulting in error spam. I deferred the call, so the editor stuff can load properly. This also makes it possible to use UIDs directly in editor plugins instead of paths.
Fixes #64881