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

Crash when unfolding image property of an ImageTexture #34482

Closed
MightyPrinny opened this issue Dec 20, 2019 · 4 comments
Closed

Crash when unfolding image property of an ImageTexture #34482

MightyPrinny opened this issue Dec 20, 2019 · 4 comments

Comments

@MightyPrinny
Copy link
Contributor

MightyPrinny commented Dec 20, 2019

Godot version:
3.2 beta 4 mono

OS/device including version:
MXLinux 64 bits

Issue description:
I had a node with a property with an ImageTexture, the image was modified in code by an editor plugin which embeds the image in the scene on save, if the image is modified while the image resource is expanded in the inspector the editor crashes.

Edit: The image was stored in the ImageTexture, not in the scene and the editor also crashed when I saved an ImageTexture with ResourceSaver as a .res file and unfolded its image property.

Steps to reproduce:
Modify image embedded in scene using a tool script while the inspector has the image resource expanded.

Minimal reproduction project:
This is the project where I found this, open GPUTilemapTest and mess around with saving, editing the map and clicking the image resource inside the map property of the tilemap in the inspector, just clicking on it after modifying the map seems to be enough to crash the editor.
GPUTilemapPlugin.zip

@MightyPrinny MightyPrinny changed the title Crash on when modifying image embedid in scene with editor plugin Crash when modifying image embedid in scene with editor plugin Dec 20, 2019
@MightyPrinny MightyPrinny changed the title Crash when modifying image embedid in scene with editor plugin Crash when modifying image embeded in scene with editor plugin Dec 20, 2019
@MightyPrinny MightyPrinny changed the title Crash when modifying image embeded in scene with editor plugin Crash when modifying image embedded in scene with editor plugin Dec 20, 2019
@qarmin
Copy link
Contributor

qarmin commented Dec 20, 2019

Backtrace

[1] /lib/x86_64-linux-gnu/libc.so.6(+0x46470) [0x7f6c6b4fc470] (??:0)
[2] Set<String, Comparator<String>, DefaultAllocator>::_find(String const&) const (/mnt/KubuntuWolne/godot/./core/set.h:224)
[3] Set<String, Comparator<String>, DefaultAllocator>::find(String const&) const (/mnt/KubuntuWolne/godot/./core/set.h:509)
[4] Set<String, Comparator<String>, DefaultAllocator>::has(String const&) const (/mnt/KubuntuWolne/godot/./core/set.h:529)
[5] Object::editor_is_section_unfolded(String const&) (/mnt/KubuntuWolne/godot/core/object.cpp:1642)
[6] EditorInspectorSection::_notification(int) (/mnt/KubuntuWolne/godot/editor/editor_inspector.cpp:1101)
[7] EditorInspectorSection::_notificationv(int, bool) (/mnt/KubuntuWolne/godot/editor/editor_inspector.h:220 (discriminator 14))
[8] Object::notification(int, bool) (/mnt/KubuntuWolne/godot/core/object.cpp:933)
[9] CanvasItem::_update_callback() (/mnt/KubuntuWolne/godot/scene/2d/canvas_item.cpp:459)
[10] MethodBind0::call(Object*, Variant const**, int, Variant::CallError&) (/mnt/KubuntuWolne/godot/./core/method_bind.gen.inc:61 (discriminator 4))
[11] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/KubuntuWolne/godot/core/object.cpp:921 (discriminator 1))
[12] MessageQueue::_call_function(Object*, StringName const&, Variant const*, int, bool) (/mnt/KubuntuWolne/godot/core/message_queue.cpp:250)
[13] MessageQueue::flush() (/mnt/KubuntuWolne/godot/core/message_queue.cpp:299)
[14] SceneTree::iteration(float) (/mnt/KubuntuWolne/godot/scene/main/scene_tree.cpp:486 (discriminator 2))
[15] Main::iteration() (/mnt/KubuntuWolne/godot/main/main.cpp:1987)
[16] OS_X11::run() (/mnt/KubuntuWolne/godot/platform/x11/os_x11.cpp:3255)
[17] godot(main+0x125) [0x13e396b] (/mnt/KubuntuWolne/godot/platform/x11/godot_x11.cpp:57)
[18] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f6c6b4dd1e3] (??:0)
[19] godot(_start+0x2e) [0x13e378e] (??:?)

@MightyPrinny MightyPrinny changed the title Crash when modifying image embedded in scene with editor plugin Crash when unfolding image property of an ImageTexture Dec 22, 2019
@akien-mga akien-mga added this to the 3.2 milestone Jan 15, 2020
@madmiraal
Copy link
Contributor

I can no longer reproduce this problem on master. However is still exists on the 3.2 branch.

Assuming we still want to solve this for 3.2, I've simplified the minimal reproduction project to this:
34482-Simplified.zip
It's a Sprite with an ImageTexture as a Texture and the Image.tres resource loaded into Image. Image.tres is just the default icon.png saved as an Image resource.

To cause the editor to crash, simply click the Image multiple times, to show and hide the underlying Resource. For me it crashes reliably on the third click i.e. show, hide, show.
Screenshot_2020-04-03_11-07-32

The crash appears to be caused by a deleted Object being assigned to the object pointer in the EditorInspectorSection. I think the problem is that the Ref<Image> that is assigned to the Object Variant by "image" via get_data() is not persistent:

bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name == "image_data") {
} else if (p_name == "image")
r_ret = get_data();
else if (p_name == "flags")
r_ret = flags;
else if (p_name == "size")
r_ret = Size2(w, h);
else
return false;
return true;
}
void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic,sRGB,Mirrored Repeat"));
p_list->push_back(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_NONE, ""));
}

However, I'm unable to workout what has changed on master to solve this.

@Xrayez
Copy link
Contributor

Xrayez commented Feb 12, 2021

Assuming we still want to solve this for 3.2, I've simplified the minimal reproduction project to this:
34482-Simplified.zip
It's a Sprite with an ImageTexture as a Texture and the Image.tres resource loaded into Image. Image.tres is just the default icon.png saved as an Image resource.

Can no longer reproduce in Godot 3.2.4 RC. Windows 10.

@akien-mga
Copy link
Member

Nice :) Closing as fixed then.

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

6 participants