godotengine / godot

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

Reparenting a bakedlightmap causes the engine to crash #28350

Open jamie-pate opened 5 years ago

jamie-pate commented 5 years ago

Godot version: 3.1 6098a7f1914f64c77d689f54d5432095911b744f

OS/device including version: Windows 10 Pro 64-bit (10.0, Build 17134) (17134.rs4_release.180410-1804) GeForce GTX 1070 with Max-Q Design/PCIe/SSE2 (plus Intel(R) UHD Graphics 630 which is disabled)

Issue description:

Generate a baked lightmap with baked textures and then try to move the lightmap into a spatial

    godot.windows.tools.64.exe!Object::call(const StringName & p_name, const Variant & p_arg1, const Variant & p_arg2, const Variant & p_arg3, const Variant & p_arg4, const Variant & p_arg5) Line 866 C++
    godot.windows.tools.64.exe!BakedLightmap::_assign_lightmaps() Line 667  C++
    godot.windows.tools.64.exe!BakedLightmap::_notification(int p_what) Line 645    C++
    godot.windows.tools.64.exe!BakedLightmap::_notificationv(int p_notification, bool p_reversed) Line 91   C++
    godot.windows.tools.64.exe!Object::notification(int p_notification, bool p_reversed) Line 954   C++
    godot.windows.tools.64.exe!Node::_propagate_ready() Line 189    C++
    godot.windows.tools.64.exe!Node::_set_tree(SceneTree * p_tree) Line 2557    C++
    godot.windows.tools.64.exe!Node::_add_child_nocheck(Node * p_child, const StringName & p_name) Line 1154    C++
    godot.windows.tools.64.exe!Node::add_child(Node * p_child, bool p_legible_unique_name) Line 1185    C++
    godot.windows.tools.64.exe!MethodBind2<Node,Node *,bool>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Variant::CallError & r_error) Line 1517    C++
    godot.windows.tools.64.exe!Object::call(const StringName & p_method, const Variant * * p_args, int p_argcount, Variant::CallError & r_error) Line 942   C++

Tries to call node->call("get_bake_mesh_instance") when node is NULL (result of get_node(light_data->get_user_path(i)))

for (int i = 0; i < light_data->get_user_count(); i++) {
        Ref<Texture> lightmap = light_data->get_user_lightmap(i);
        ERR_CONTINUE(!lightmap.is_valid());

        Node *node = get_node(light_data->get_user_path(i)); // <- node is set to NULL here, i == 1

Steps to reproduce: Open sample project, move $BakedLightMap node inside $Spatial

Minimal reproduction project:

baked_light_map_crash.zip

KoBeWi commented 4 years ago

The problem here is that lightmap data has nodes stored as NodePaths. To fix this, these paths need to be updated after each move.

I tried to do this, but ultimately got stuck. You can move the BakedLightMap to Spatial2 in the included project, but you can't move it to parent. Here's the patch if someone wants to continue the work: https://pastebin.com/T0NgGkwB

Calinou commented 4 years ago

@jamie-pate Can you reproduce this in the master branch with the new lightmapper?

jamie-pate commented 4 years ago

I can't figure out how to add a meshlib to the bakedlightmap, i generated a meshlib where the meshintance had 'baking' enabled but image

See attached 'updated' poc baked_light_map_crash4.zip

Calinou commented 2 years ago

@jamie-pate Can you (or anyone else) still reproduce this bug in Godot 3.4 or any later release?

If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop.

jamie-pate commented 2 years ago

Yes it still crashes in 3.4.2

bakedlightmap_crash.zip lightmapcrash

Here is a stack trace from 3.3.4 (the latest version I have on hand with a debug build)


ERROR: get_node: (Node not found: "../MeshInstance" (relative to "/root/EditorNode/@@580/@@581/@@589/@@591/@@595/@@599/@@600/@@601/@@617/@@618/@@627/@@628/@@6060/@@5899/@@5900/@@5901/@@5902/@@5903/Spatial/Spatial2/BakedLightmap").)
   At: scene/main/node.cpp:1371.
ERROR: _assign_lightmaps: Condition "!vi" is true. Continuing.
   At: scene/3d/baked_lightmap.cpp:1206.
ERROR: get_node: (Node not found: "../GridMap" (relative to "/root/EditorNode/@@580/@@581/@@589/@@591/@@595/@@599/@@600/@@601/@@617/@@618/@@627/@@628/@@6060/@@5899/@@5900/@@5901/@@5902/@@5903/Spatial/Spatial2/BakedLightmap").)
   At: scene/main/node.cpp:1371.
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x46520) [0x7fbcfcd38520] (??:0)
[2] Object::call(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (/home/jpate/src/godot/core/object.cpp:845)
[3] BakedLightmap::_assign_lightmaps() (/home/jpate/src/godot/scene/3d/baked_lightmap.cpp:1198 (discriminator 4))
[4] BakedLightmap::_notification(int) (/home/jpate/src/godot/scene/3d/baked_lightmap.cpp:1173)
[5] BakedLightmap::_notificationv(int, bool) (/home/jpate/src/godot/scene/3d/baked_lightmap.h:106 (discriminator 14))
[6] Object::notification(int, bool) (/home/jpate/src/godot/core/object.cpp:931)
[7] Node::_propagate_ready() (/home/jpate/src/godot/scene/main/node.cpp:197)
[8] Node::_set_tree(SceneTree*) (/home/jpate/src/godot/scene/main/node.cpp:2626)
[9] Node::_add_child_nocheck(Node*, StringName const&) (/home/jpate/src/godot/scene/main/node.cpp:1154)
[10] Node::add_child(Node*, bool) (/home/jpate/src/godot/scene/main/node.cpp:1169)
[11] MethodBind2<Node*, bool>::call(Object*, Variant const**, int, Variant::CallError&) (/home/jpate/src/godot/./core/method_bind.gen.inc:1523 (discriminator 19))
[12] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/home/jpate/src/godot/core/object.cpp:919 (discriminator 1))
[13] UndoRedo::_process_operation_list(List<UndoRedo::Operation, DefaultAllocator>::Element*) (/home/jpate/src/godot/core/undo_redo.cpp:294 (discriminator 4))
[14] UndoRedo::redo() (/home/jpate/src/godot/core/undo_redo.cpp:338)
[15] UndoRedo::commit_action() (/home/jpate/src/godot/core/undo_redo.cpp:260)
[16] SceneTreeDock::_do_reparent(Node*, int, Vector<Node*>, bool) (/home/jpate/src/godot/editor/scene_tree_dock.cpp:1825)
[17] SceneTreeDock::_nodes_dragged(Array, NodePath, int) (/home/jpate/src/godot/editor/scene_tree_dock.cpp:2524 (discriminator 5))
[18] MethodBind3<Array, NodePath, int>::call(Object*, Variant const**, int, Variant::CallError&) (/home/jpate/src/godot/./core/method_bind.gen.inc:2303 (discriminator 26))
[19] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/home/jpate/src/godot/core/object.cpp:919 (discriminator 1))
[20] Object::emit_signal(StringName const&, Variant const**, int) (/home/jpate/src/godot/core/object.cpp:1246 (discriminator 1))
[21] Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (/home/jpate/src/godot/core/object.cpp:1304)
[22] SceneTreeEditor::drop_data_fw(Vector2 const&, Variant const&, Control*) (/home/jpate/src/godot/editor/scene_tree_editor.cpp:1081 (discriminator 8))
[23] MethodBind3<Vector2 const&, Variant const&, Control*>::call(Object*, Variant const**, int, Variant::CallError&) (/home/jpate/src/godot/./core/method_bind.gen.inc:2303 (discriminator 26))
[24] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/home/jpate/src/godot/core/object.cpp:919 (discriminator 1))
[25] Object::call(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (/home/jpate/src/godot/core/object.cpp:846)
[26] Control::drop_data(Vector2 const&, Variant const&) (/home/jpate/src/godot/scene/gui/control.cpp:769 (discriminator 6))
[27] Viewport::_gui_drop(Control*, Vector2, bool) (/home/jpate/src/godot/scene/main/viewport.cpp:1879)
[28] Viewport::_gui_input_event(Ref<InputEvent>) (/home/jpate/src/godot/scene/main/viewport.cpp:2069)
[29] Viewport::input(Ref<InputEvent> const&) (/home/jpate/src/godot/scene/main/viewport.cpp:2923 (discriminator 2))
[30] Viewport::_vp_input(Ref<InputEvent> const&) (/home/jpate/src/godot/scene/main/viewport.cpp:1482)
[31] MethodBind1<Ref<InputEvent> const&>::call(Object*, Variant const**, int, Variant::CallError&) (/home/jpate/src/godot/./core/method_bind.gen.inc:775 (discriminator 12))
[32] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/home/jpate/src/godot/core/object.cpp:919 (discriminator 1))
[33] Object::call(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (/home/jpate/src/godot/core/object.cpp:846)
[34] SceneTree::call_group_flags(unsigned int, StringName const&, StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (/home/jpate/src/godot/scene/main/scene_tree.cpp:276)
[35] SceneTree::input_event(Ref<InputEvent> const&) (/home/jpate/src/godot/scene/main/scene_tree.cpp:432 (discriminator 6))
[36] InputDefault::_parse_input_event_impl(Ref<InputEvent> const&, bool) (/home/jpate/src/godot/main/input_default.cpp:456)
[37] InputDefault::parse_input_event(Ref<InputEvent> const&) (/home/jpate/src/godot/main/input_default.cpp:273)
[38] InputDefault::flush_accumulated_events() (/home/jpate/src/godot/main/input_default.cpp:692)
[39] OS_X11::process_xevents() (/home/jpate/src/godot/platform/x11/os_x11.cpp:2897)
[40] OS_X11::run() (/home/jpate/src/godot/platform/x11/os_x11.cpp:3639)
[41] /home/jpate/src/godot/bin/godot.x11.tools.64(main+0x131) [0x16f8857] (/home/jpate/src/godot/platform/x11/godot_x11.cpp:57)
[42] /lib/x86_64-linux-gnu/libc.so.6(+0x2dfd0) [0x7fbcfcd1ffd0] (??:0)
[43] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x7d) [0x7fbcfcd2007d] (??:0)
[44] /home/jpate/src/godot/bin/godot.x11.tools.64(_start+0x25) [0x16f8665] (??:?)
clayjohn commented 1 year ago

I can't reproduce this in RC3. Accordingly I am marking this as fixed for 4.0, will re-target to 3.x