Skip to content
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

Godot keeps changing ids in theme #74001

Open
MunWolf opened this issue Feb 26, 2023 · 25 comments
Open

Godot keeps changing ids in theme #74001

MunWolf opened this issue Feb 26, 2023 · 25 comments

Comments

@MunWolf
Copy link
Contributor

MunWolf commented Feb 26, 2023


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
Copy link
Contributor

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
Copy link
Contributor Author

MunWolf commented Feb 26, 2023

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
Copy link
Contributor

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
Copy link
Contributor Author

MunWolf commented Feb 26, 2023

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
Copy link
Contributor Author

MunWolf commented Mar 1, 2023

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

@hsandt
Copy link
Contributor

hsandt commented Jun 2, 2023

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
Copy link
Contributor

hsandt commented Jul 6, 2023

I forgot the post the issue I created for Material ID: #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
Copy link
Contributor

Rindbee commented Sep 11, 2023

texture = RenderingServer::get_singleton()->texture_2d_create(p_image);

Ref<Image> image = _validate_texture_format(p_image, ret_format);

Ref<Image> TextureStorage::_validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format) {
Ref<Image> image = p_image->duplicate();

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
Copy link
Contributor

Rindbee commented Sep 11, 2023

Similar to #55190.

@citizenll
Copy link
Contributor

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
Copy link

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

This comment was marked as off-topic.

@3ter
Copy link

3ter commented May 12, 2024

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

@jamie-pate
Copy link
Contributor

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
Copy link

3ter commented May 18, 2024

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
Copy link

tinwe commented Jul 23, 2024

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
Copy link
Contributor

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
Copy link

tinwe commented Jul 24, 2024

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
Copy link
Member

KoBeWi commented Jul 24, 2024

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
Copy link

myyk commented Jul 24, 2024 via email

DanielKinsman added a commit to DanielKinsman/whos-a-good-boy that referenced this issue Jul 30, 2024
@DDarby-Lewis
Copy link

DDarby-Lewis commented Aug 24, 2024

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
Copy link

myyk commented Aug 25, 2024

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

@KoBeWi
Copy link
Member

KoBeWi commented Aug 25, 2024

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

@basilicon
Copy link

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
Copy link

3ter commented Sep 23, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests