godotengine / godot

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

AtlasTexture saved with region 0,0,0,0 (no region) spams error in console #28691

Open Ranoller opened 5 years ago

Ranoller commented 5 years ago

Godot version:

7018de8425e8c2781071595fdcf565acdfde2be4

OS/device including version:

win 7 64

Issue description:

Saving an Atlas texture with not region (x=0, y=0, w=0,h=0) will allways spam thit at the project open: AtalsSpam Problem is not the warning... problem is that you don´t know what texture is failing, so in a big project you can have that mensage allways spamming at open and you will never find what is causing that.

Steps to reproduce: Save an atlas texture to a tres file with no region.

Edit: i will copy error in text for googling help purpose:

Image::create: Index p_widht - 1=-1 out of size (MAX_WIDTH=16384) At: core\image.cpp:1443 Image::blit_rect: Condition ' dsize == 0 ' is true. At: core\image.cpp:1927

bojidar-bg commented 5 years ago

Here is a backtrace of the error:

#0  Image::create (this=0x7fffc40e2270, p_width=0, p_height=0, p_use_mipmaps=true, p_format=Image::FORMAT_DXT1) at core/image.cpp:1443
#1  0x00000000043d1c13 in Image::Image (this=0x7fffc40e2270, p_width=0, p_height=0, p_use_mipmaps=true, p_format=Image::FORMAT_DXT1) at core/image.cpp:1864
#2  0x00000000043d20ff in Image::get_rect (this=0xc1b2c50, p_area=...) at core/image.cpp:1917
#3  0x0000000002b7cbde in EditorTexturePreviewPlugin::generate (this=0xaa24740, p_from=..., p_size=...) at editor/plugins/editor_preview_plugins.cpp:101
#4  0x00000000027155d8 in EditorResourcePreviewGenerator::generate_from_path (this=0xaa24740, p_path=..., p_size=...) at editor/editor_resource_preview.cpp:71
#5  0x0000000002717f8c in EditorResourcePreview::_generate_preview (this=0x7b0f3b0, r_texture=..., r_small_texture=..., p_item=..., cache_base=...)
    at editor/editor_resource_preview.cpp:153
#6  0x0000000002716a3e in EditorResourcePreview::_thread (this=0x7b0f3b0) at editor/editor_resource_preview.cpp:242
#7  0x000000000271616d in EditorResourcePreview::_thread_func (ud=0x7b0f3b0) at editor/editor_resource_preview.cpp:93
#8  0x00000000023d0eb9 in ThreadPosix::thread_callback (userdata=0xb649ae0) at drivers/unix/thread_posix.cpp:74
#9  0x00007ffff74f7a92 in start_thread () from /usr/lib/libpthread.so.0
#10 0x00007ffff7130cd3 in clone () from /usr/lib/libc.so.6

The error comes from the fact that width - 1 = -1 which is less than 0. Not sure if images with width or height of 0 cause problems though.

The check was added in #18629, CC @raphael10241024.

Raphael2048 commented 5 years ago

I just copied the code from a creation function below. I think an image with width or height of 0 should not be allowed, we shouldn't try to create an image when atlas contains nothing.

Ranoller commented 5 years ago

Main problem with this issue is not the error, is the problem of the unindentified texture. The error doesn´t help in a project with thousand of images, you can´t find the failure manually, it can be a png, a region, etc... ,error should give to the user the path to the failing resource.

akien-mga commented 2 years ago

Seems to be fixed in 3.4.2 (no error).

Edit: Actually I can reproduce it, but for some reason the error was not shown in the Output panel and only in the console:

ERROR: Image width must be greater than 0.
   at: create (core/image.cpp:1736)
ERROR: Condition "dsize == 0" is true.
   at: blit_rect (core/image.cpp:2231)