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

Change some image error messages to output the file path #94947

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

ChrisBase
Copy link
Contributor

@ChrisBase ChrisBase commented Jul 30, 2024

Test environment

Godot Engine v4.3.rc1.official
Windows 11 Pro, Version 23H2, Build 22631.3880

Issue

TextureStorage::texture_2d_get() and TextureStorage::texture_2d_layer_get() do not print the path of the affected texture image when they fail. This is how an example output currently looks like:

● Expected Image data size of 1010x277x1 (DXT5 RGBA8 with 9 mipmaps) = 378896 bytes, got 379184 bytes instead.
● drivers\gles3\storage\texture_storage.cpp:1043 - Condition "image->is_empty()" is true. Returning: Ref<Image>()

This makes it hard to find and fix the affected image file.

Fix

The fix replaces some ERR_FAIL_COND_V() with ERR_FAIL_COND_V_MSG() to also output the file path. The output then looks like this:

● Expected Image data size of 1010x277x1 (DXT5 RGBA8 with 9 mipmaps) = 378896 bytes, got 379184 bytes instead.
● Texture with path 'res://assets/images/placeholder.png' has no data.

@ChrisBase ChrisBase requested a review from a team as a code owner July 30, 2024 11:47
@AThousandShips AThousandShips changed the title Changed some image error messages to output the file path Change some image error messages to output the file path Jul 30, 2024
@AThousandShips AThousandShips added this to the 4.x milestone Jul 30, 2024
@Calinou
Copy link
Member

Calinou commented Jul 31, 2024

I suggest applying the same change in RenderingDevice, so this also impacts the Forward+ and Mobile rendering methods. Otherwise, the improved error messages will only be visible when using the Compatibility rendering method.

@RandomShaper
Copy link
Member

RandomShaper commented Jul 31, 2024

Also, bear in mind that (I think) not all textures will have a path (programatically created).

Also, the wording of the message feels a bit werid to me.

I'd suggest something like this:

if (image->is_empty()) {
    const String& path_str = texture->path.is_empty() ? "with no path" : vformat("with path '%s'", texture->path));
    ERR_FAIL_V_MSG(Ref<Image>(), vformat("Texture (%s) has no data.
}

@ChrisBase
Copy link
Contributor Author

@Calinou @RandomShaper

Thank you both for your feedback. I updated the PR accordingly.

@RandomShaper
Copy link
Member

I think this is good enough for now, but if may be good to refactor these blocks into something more compact, such as a (maybe templated) utility function in RendererTextureStorage. For the time being, I'll give my approval, but other contributors may think it's better to do the refactor now.

@Mickeon Mickeon requested a review from a team November 13, 2024 22:41
@Mickeon
Copy link
Contributor

Mickeon commented Nov 13, 2024

This could use a rebase and perhaps someone else from the rendering team could take a look at it, too.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good to merge after squashing commits together (see PR workflow for details).

@AThousandShips AThousandShips removed request for a team November 16, 2024 10:52
@KoBeWi KoBeWi modified the milestones: 4.x, 4.4 Dec 11, 2024
@Repiteo Repiteo merged commit ef3086b into godotengine:master Dec 11, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 11, 2024

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.

Error messages for failed image imports do not print the affected file path
7 participants