godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.7k stars 21.11k forks source link

Godot keeps changing ids in theme #74001

Open MunWolf opened 1 year ago

MunWolf commented 1 year ago

Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version

4.0 rc5

System information

Windows 10 and Linux

Issue description

My friend and I are working on a game and we have a theme that we use for all of our UI.

We created it by importing it from the default theme and making some changes (not very important as this was happening before we made the changes)

Every time we save the project if the person who was saving isn't the last one to have commited a change to the theme it changes all the ids on the entries

Example image image

Notably I am working on the windows release of rc5 while my friend is on the linux release, I assume that has something to do with this issue.

Steps to reproduce

  1. Make a project on the windows version of godot
  2. Make a theme
  3. Save the project
  4. Commit it to git source control
  5. Load the project with the linux version of godot
  6. Save the project
  7. Notice that git status shows changes on the theme, which only includes changes to the resource ids

Minimal reproduction project

N/A

YuriSizov commented 1 year ago

Judging by your screenshot, this happens with the bundled font, and is kind of expected. For the record, you don't have to make a copy of the entire default theme, and at the very least you don't have to bundle the fonts. Themes merge together, and your project theme only needs to contain the parts that you override from the default one.

MunWolf commented 1 year ago

That is interesting, because this is what we have in the theme and I don't see any fonts there image We initially copied the whole theme and then deleted a bunch of things later on. Did the font data stick around? EDIT: Here is the theme file for reference default.zip

YuriSizov commented 1 year ago

Well, I can be wrong, there is only so much I can tell from a screenshot. If you can't provide an MRP, you can try debugging it yourself by recreating the theme anew and adding only the stuff you need.

MunWolf commented 1 year ago

Seems like there was 1 font on the label, but it does not show up in the Edit Items window, only when I try to import from it into another theme. image Importing to another theme and ignoring that one font reduced the file massively so I assume that fixed it So the issue here is more that the font did not show up in the Edit Items window. (if the IDs changing is intended)

The ids that change seem to also include icons so I removed those as well.

MunWolf commented 1 year ago

As an update, including any fonts or textures in your theme from the default theme causes this issue.

hsandt commented 1 year ago

I have the same issue, and it seems to affect ImageTexture IDs specifically.

The effect is similar to how a material flagged Local to Scene keeps changing its ShaderMaterial ID (an issue I have yet to report, as I'll try to make a MRP first), but since this is a resource and there is no Local to Scene to check, the cause must be different.

hsandt commented 1 year ago

I forgot the post the issue I created for Material ID: https://github.com/godotengine/godot/issues/77997 although the cause must be different since it only happens when checking Local to Scene (and this seems to apply to other resources as well)

Rindbee commented 1 year ago

https://github.com/godotengine/godot/blob/fc99492d3066098e938449b10e02f8e01d07e2d1/scene/resources/image_texture.cpp#L93

https://github.com/godotengine/godot/blob/fc99492d3066098e938449b10e02f8e01d07e2d1/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp#L796

https://github.com/godotengine/godot/blob/fc99492d3066098e938449b10e02f8e01d07e2d1/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp#L1566-L1567

Setting Image for ImageTexture ultimately sets a copy of the original image. And the copy does not retain the scene_unique_id of the original image. A new scene_unique_id will be generated when the file is saved.

It seems that the image of ImageTexture exists in the form of data, not an object.

Rindbee commented 1 year ago

Similar to #55190.

citizenll commented 1 year ago

At the same time, I feel the need to solve a problem. When I copy a node, such as an animation_player, the id of the sub_resource does not change. This can lead to confusing issues. Here is my case: I am currently creating multiple monsters, some of which require AnimationPlayer and Sprite2D nodes. After creating one monster, I want to quickly copy these two nodes to other monster nodes. I expect the nodes to be copied normally. However, the AnimationPlayer node is actually copied with the same id as the resource type, and when I make changes to other monsters, the previous monster is unknowingly affected and damaged.

Serotonindude commented 9 months ago

same here... it changes the theme file even if i don't change anything in the theme... got a changed theme file on every commit...

Jagholin commented 9 months ago

yes this currently drives me nuts I have a theme file in the project, that I dont even touch Every time I start godot, just start, I dont even change anything The Theme file is modified again... Why?

3ter commented 5 months ago

Can someone just shortly reiterate what the current workaround is (except for ignoring the id changes)?

jamie-pate commented 5 months ago

As an update, including any fonts or textures in your theme from the default theme causes this issue.

Remove resources (fonts/textures) from your theme file that reference the default theme or maybe make them unique?

3ter commented 5 months ago

Thanks a ton @jamie-pate !

~This button did the trick for me~ image

EDIT: No, that was the wrong button. This one (local to scene) also didn't do the trick image

I couldn't find any resources that were referencing the default theme (it should be in the resource path, am I right? all of those referenced my own theme).

tinwe commented 3 months ago

We have the same issue and it's driving me crazy that default_theme.tres keeps changing just because it decides to change IDs, so that file gets commited in Github every single commit.

DanielKinsman commented 3 months ago

Here is my absurd workaround that possibly might have bad consequences for the integrity of your project:

  1. put the theme tres in a subdirectory all of its own
  2. remove permissions from that directory and the tres file so you can't write to it (e.g. chown & chmod to root)

Godot will complain about not being able to write to the file whenever you save, but it appears to work...

tinwe commented 3 months ago

Here is my absurd workaround that possibly might have bad consequences for the integrity of your project:

1. put the theme tres in a subdirectory all of its own

2. remove permissions from that directory and the tres file so you can't write to it (e.g. chown & chmod to root)

Godot will complain about not being able to write to the file whenever you save, but it appears to work...

Thanks for the suggestions, but that's not really a viable workaround for us, and I find it rather absurd. Has there been any official word about this bug yet?

KoBeWi commented 3 months ago

The ID change because you have ImageTexture embedded in your Theme. Trying to get Image of ImageTexture will always return a new instance (#25209), hence the IDs will change.

We already have a warning when importing theme icons: image I guess it could clarify what does it mean exactly or maybe it should be outright not allowed, because icons imported from default/editor theme get embedded. The only way to "fix" this is to save each icon to a new file, so it gets referenced as an external dependency.

myyk commented 3 months ago

I think the warning doesn't really let you know how it's not just bigger but it's unstable and will change frequently which makes it practically incompatible with source control .

On Wed, Jul 24, 2024, 21:48 Tomek @.***> wrote:

The ID change because you have ImageTexture embedded in your Theme. Trying to get Image of ImageTexture will always return a new instance (#25209 https://github.com/godotengine/godot/issues/25209), hence the IDs will change.

We already have a warning when importing theme icons: image.png (view on web) https://github.com/user-attachments/assets/6ecb3466-820d-480f-98f5-aa7383cf3914 I guess it could clarify what does it mean exactly or maybe it should be outright not allowed, because icons imported from default/editor theme get embedded. The only way to "fix" this is to save each icon to a new file, so it gets referenced as an external dependency.

— Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/74001#issuecomment-2247994925, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP4ANGESGCGROCLYOYODM3ZN6WCTAVCNFSM6AAAAAAVIUBDYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBXHE4TIOJSGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

DDarby-Lewis commented 2 months ago

This isn't an issue with themes I don't think - I am using ImageTexture in my project and every time the project loads the internal id of the sub-resource containing the image data is changed. The IDs change even when no changes to the image occur - i.e. just opening and closing the editor changes the IDs, I assume it is the loading and unloading of the resource that does it.

I have tried everything I can think of and everything recommended on other threads to try and fix this but nothing works. I have even written a system that saves the image as a PNG before loading it into the ImageTexture, hoping that that would sort it but no luck.

This the the kind of ID that keeps changing in the ImageTexture:

[sub_resource type="Image" id="Image_spgdd"]
data = {
...
}

image = SubResource("Image_spgdd")

If anyone has any ideas I'd be very grateful.

myyk commented 2 months ago

For me, (I think) it was that I had to recreate my theme without starting from a copy of the default theme.

KoBeWi commented 2 months ago

Save the Image as file instead of embeddimg it. From the inspector, not using script.

basilicon commented 1 month ago

Yes, this is an issue with images being embedded in the theme. This can happen when you don't set a texture for a type; it will load the default texture into your theme, and directly embed the data into your theme as a SubResource. To fix this:

  1. Look at your theme changes in Git and find the id of the image that is changing. image
  2. Open your theme in your preferred text editor, and find where the image is being used (for me it is an ImageTexture). image
  3. For each id, find where else that is being used; take note of what icon it is being used for (for me it is the LineEdit clear icon). image
  4. In the theme editor in Godot, just clear that associated image, and the embedding disappears. Alternatively, you can right click the image and Save As, if you are using your own custom texture. image

This will remove the embedded data for the texture. When you play the game, it will still use the texture, it just doesn't load it directly from the theme now. I don't know why this happens, but I think it can occur during some point of setting up a theme for a certain type for the first time, but other than that I genuinely have no idea how to reproduce this issue.

3ter commented 1 month ago

@basilicon Thank you so much for the step by step solution that at last I was able to follow. Your post will be remembered! Now I don't care that much anymore if it's fixed or not, this workaround is sufficient for me.