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

Do not print error when editor meta was not found as it will be reimported anyway after #86137

Merged
merged 1 commit into from
Dec 16, 2023

Conversation

Maran23
Copy link
Contributor

@Maran23 Maran23 commented Dec 14, 2023

Fixes: #85859

The error is printed when the editor metadata files for a particular image were not found,
which can happen when you check out a new project or clean up your .godot folder.

But this is not really necessary, as Godot will reimport the file afterwards anyway,
because it detects that the metadata are not up to date (in this case it does not even exist).

The following is now changed:

  • Deleted all 4 files (ctex, editor.ctex, editor.meta, md5) (happens for a newly checked out project)
    • Before: Error
    • Now: Will be recreated, no error
  • Deleted editor.meta
  • Deleted editor.ctex
    • Before: Error
    • After: Will be recreated, no error
  • Deleted ctex
    • Same as before (recreate)
  • Deleted md5
    • Same as before (recreate)

cc @YuriSizov I would be interested in your opinion as you have added this error line in #75949, just in case I miss something here. 🙂

@YuriSizov
Copy link
Contributor

YuriSizov commented Dec 14, 2023

But this is not really necessary, as Godot will reimport the file afterwards anyway

That's only true because you've removed all the contents of the .godot folder. However, if only the metadata file is missing then we won't reimport anything, unless there are other reasons to do so. Check the logic of ResourceImporterTexture::are_import_settings_valid. We return an empty dictionary, which means we will never check if import settings are valid because we have nothing to compare against.

The error prints an actionable message for the user in this case. Which was especially important when the change was introduced, as existing projects would have imported textures but not metadata files.

If the message appears under some circumstances which are valid and don't require user action, then the change should be to handle those situations gracefully rather than remove the message completely.

Edit: We can also handle the entire thing differently. Instead of returning an empty dictionary we can pass a dictionary reference to the parameters and fill it, and return an error code instead. So we can differentiate between "there is meta but it's empty" and "there is no meta".

The key things to keep in mind here is that we want to make sure we don't trigger reimport unless there is a reason to reimport. So missing meta may not be an invalid state, it may just mean that user didn't enable the relevant import setting. So ideally we still want to only exclude cases where everything is missing, but print the message in every other situation.

@Maran23
Copy link
Contributor Author

Maran23 commented Dec 14, 2023

Changed the logic to check if the file exist.
Not sure about the "there is meta but it's empty" case.
Before and right now, nothings happens if the file exists but there is nothing in it.
If I got you right, we also want to handle the case where the dictionary is completely empty?
-> If yes, I can change it.

The new logic right now works like this:

  • Deleted all 4 files (ctex, editor.ctex, editor.meta, md5): Will be recreated, no error
  • Deleted editor.meta: Will be recreated, no error
  • Deleted editor.ctex: Errors:
    Unable to open file: res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.editor.ctex.
    Failed loading resource: res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.editor.ctex. Make sure resources have been imported by opening the project in the editor at least once.
    Failed loading resource: res://icon.svg. Make sure resources have been imported by opening the project in the editor at least once.
  • Deleted ctex: Will be recreated, no error
  • Deleted md5: Will be recreated, no error

Although now the Missing required editor-specific import metadata ... will not be printed anymore as we do check the case of an non-existing file before.

@YuriSizov
Copy link
Contributor

YuriSizov commented Dec 14, 2023

You did the exact opposite of what I was describing 🙃 The only case where we don't want an error is when ctex is missing, because we will regenerate the file anyway. In other cases there should be an error.

@Maran23
Copy link
Contributor Author

Maran23 commented Dec 14, 2023

You did the exact opposite of what I was describing 🙃 The only case where we don't want an error is when ctex is missing, because we will regenerate the file anyway. In other cases there should be an error.

I think you are mixing this up. I did not change the editor.ctex or ctex handling here (also not md5).
And regardless, it looks fine as in this case we really need to reimport the texture to fix the scene(s) using the corresponding texture.

The only thing that is changed is when there is no editor.meta file (or even all files are missing, like for new projects).
In this case we can return false and let Godot regenerate the file.

Let us elaborate on this. What should happen for what case?

  • All (editor) import files missing
  • editor.meta missing
  • editor.ctex missing
  • ctex missing (not editor specific, so probably does not matter for this PR)
  • md5 missing (not editor specific, so probably does not matter for this PR)

@YuriSizov
Copy link
Contributor

I think you are mixing this up. I did not change the editor.ctex or ctex handling here (also not md5).

That's not what I was suggesting, but I did misread what kind of error we show in your bulletpoint list above. Point still stands, though, as I suggested we should show the error when the meta file is missing and we should reimport the icon without any issues if the ctex file is missing.

If non-editor ctex and editor ctex are handled differently by the engine right now, and the latter errs where the former doesn't, it's a problem that needs to be addressed (but not necessarily right here and right now).


The reason why we err when the meta file is missing is, as I explained, compatibility. Existing projects that predate the meta file can already have correctly imported textures which would work just fine without a reimport. The meta file is only needed to check for a reimport, it's not needed for the runtime. But we still want to tell users that they need to reimport affected textures to update them to the latest format of the metadata.

If we decide that we don't care about this anymore, then sure, we can go with the way this PR is right now and just treat missing meta files as a reason to force a reimport.

However, if we want to preserve this logic and address your issue at the same time, then we should check if the editor.ctex file is missing and if it is, avoid throwing the message because the reimport will happen regardless. I'm fine with whatever option, but I hope you understand the logic better now.

… be reimported after and no error is printed
@Maran23
Copy link
Contributor Author

Maran23 commented Dec 14, 2023

However, if we want to preserve this logic and address your issue at the same time, then we should check if the editor.ctex file is missing and if it is, avoid throwing the message because the reimport will happen regardless. I'm fine with whatever option, but I hope you understand the logic better now.

Ahh, yes, I got you now. Thanks for explaining the details here. I did not fully understand the 'dependency' between the editor.ctex and editor.meta file I'm afraid.

Behaviour now:

  • Deleted all 4 files (ctex, editor.ctex, editor.meta, md5): Will be recreated, no error
  • Deleted editor.meta:
    Error: Missing required editor-specific import metadata for a texture (please reimport it using the 'Import' tab): 'res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.editor.meta'
  • Deleted editor.ctex: Will be recreated, no error
  • Deleted ctex: Will be recreated, no error
  • Deleted md5: Will be recreated, no error

Looks much better. :)

@YuriSizov YuriSizov merged commit e63f1d4 into godotengine:master Dec 16, 2023
15 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

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

Successfully merging this pull request may close these issues.

Missing required editor-specific import metadata for a texture ... when checking out a new project/plugin
3 participants