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

Drag and drop and node selection slowdown in the editor since version 3.4.beta2 #51188

Closed
pixel-boy opened this issue Aug 2, 2021 · 12 comments
Closed

Comments

@pixel-boy
Copy link

Godot version

3.4.beta2

System information

Windows 7

Issue description

In some of my projects (especially the bigger ones) drag and drop file from file system to scene can be really slow, depending on the node selected in the tree (Particles2d type node is on of the most affected) I tried with the stable 3.3.2 version and there is no problem.

The other notable problem concerns the profiler, which once activated slows down the game and makes it unplayable (which is not the case in version 3.3.2 stable).

I tried on another computer and the problems are also there.

By gradually removing the content of the project the drag and drop bug disappears, but it is difficult to know if the problem comes from certain elements or the amount of content.

I modified some project options, tried to disabled those related to batching that seemed recent, but nothing corrects the bug.

I also tried to reproduce the problem in an empty project but was not successful.

Steps to reproduce

In some projects (those with a lot of content in my case):

  • create an empty scene with a Particles2D as root node
  • drop file (png, script or other) from file system to scene

GIF: https://i.imgur.com/wzeWjcE.gif

Minimal reproduction project

I failed to reproduce a minimal version, if it's necessary I can import a project which has the bug but like I said these are projects with a lot of content

@Calinou
Copy link
Member

Calinou commented Aug 2, 2021

If you can compile the editor from source, can you try bisecting the regression? This would greatly speed up troubleshooting 🙂

Also, can you reproduce this in the 3D editor (e.g. when dragging OBJ/DAE/glTF files)?

@pixel-boy
Copy link
Author

If you can compile the editor from source, can you try bisecting the regression? This would greatly speed up troubleshooting

I can try but I am not familiar with versioning and compiling Godot from source, I am afraid it will be a bit complicated, can I help otherwise ?

Also, can you reproduce this in the 3D editor (e.g. when dragging OBJ/DAE/glTF files)?

I reproduced the problem in a 3D scene by dragging an OBJ into the scene, the bug is still there, in the end the problem seems only related to the node selected in the scene tree, no matter what I drag (png,tscn,obj etc...) it always takes the same time.

In this gif I drag an OBJ (the result is the same with a PNG) and drop it on different nodes type:
https://i.imgur.com/100ao3d.gif

The result:
no node selected -> no delay
Spatial node -> slight delay
Particles node -> average delay
Mesh Instance node -> the longest

@Calinou
Copy link
Member

Calinou commented Aug 2, 2021

This could be a regression from #51011, but I'm not 100% sure yet. For 3D, maybe #50713 plays a role in the regression too.

@akien-mga
Copy link
Member

This could be a regression from #51011, but I'm not 100% sure yet. For 3D, maybe #50713 plays a role in the regression too.

Neither PR are included in 3.4 beta 2 (it was built on Monday from a71169c). So the regression must be older (and can go all the way back to 3.3-stable for a change not cherry-picked to 3.3).

@akien-mga
Copy link
Member

I tried to make https://github.com/KOBUGE-Games/jetpaca "big" by duplicate the art and stages folders many times but I didn't manage to reproduce the issue aside from tiny lags when dragging a very big spritesheet for the first time, but it's hard to say if they're related to this issue.

If you're able to share your big project privately (e.g. sending me a link via a Twitter DM or email), I can see if I'm able to reproduce it then, and bisect the change that introduced the issue.

Alternatively, I can make some intermediate Godot builds for Windows between 3.3-stable and 3.4-beta2 to narrow down when the change happened some more (i.e. an async bisect, can take a while :)).

@pixel-boy
Copy link
Author

I tried to make https://github.com/KOBUGE-Games/jetpaca "big" by duplicate the art and stages folders many times but I didn't manage to reproduce the issue aside from tiny lags when dragging a very big spritesheet for the first time, but it's hard to say if they're related to this issue.

Yes I also tried to do that without success, so it may be more related to a specific element.
I sent you one of the project via twitter DM.

@akien-mga
Copy link
Member

I sent you one of the project via twitter DM.

Got it, thanks. And I can reproduce the bug too 🎉

I'll get it bisected tomorrow.

@akien-mga akien-mga self-assigned this Aug 2, 2021
@akien-mga
Copy link
Member

akien-mga commented Aug 3, 2021

I finished bisecting, the culprit seems to be b622dfa (from #49491). @pycbouh

b622dfa956de2604bf514d8f031ac252477cce1e is the first bad commit
commit b622dfa956de2604bf514d8f031ac252477cce1e
Author: Yuri Sizov <yuris@humnom.net>
Date:   Thu Jun 10 19:48:35 2021 +0300

    Use EditorResourcePicker in the Inspector
    
    Backported from #48854

 doc/classes/EditorSpinSlider.xml        |   2 +
 editor/editor_properties.cpp            | 771 +++++---------------------------
 editor/editor_properties.h              |  60 +--
 editor/editor_properties_array_dict.cpp |   2 +-
 4 files changed, 126 insertions(+), 709 deletions(-)
$ git bisect log
git bisect start
# bad: [207fb165bfd1fefd1b4339c9427a569b19d0dcae] [HTML5] Raise default initial memory to 32 MiB.
git bisect bad 207fb165bfd1fefd1b4339c9427a569b19d0dcae
# good: [8e68f2e5f48c66bfa80b9bb7746a488afb70086d] Bump version to 3.3-stable \o/
git bisect good 8e68f2e5f48c66bfa80b9bb7746a488afb70086d
# good: [59b6950034ac528759f664d570669dc2425bd92a] Merge pull request #48993 from kleonc/sprite_frames_editor-zoom-hidpi
git bisect good 59b6950034ac528759f664d570669dc2425bd92a
# bad: [6c07784dbabc5ca1578c65340244d24cc8402453] Validate parameters when adding plugins
git bisect bad 6c07784dbabc5ca1578c65340244d24cc8402453
# good: [6580166f39064e05f69d6a99b6506d14092d4945] Merge pull request #48693 from Calinou/editor-import-invert-green-channel-3.x
git bisect good 6580166f39064e05f69d6a99b6506d14092d4945
# bad: [9be9304238a23d7850b58bc32ea07f054964b5ec] Improve the console error logging appearance
git bisect bad 9be9304238a23d7850b58bc32ea07f054964b5ec
# good: [0d68db1b85ea4b4dcce3ba46837b868025e9be96] Merge pull request #49280 from timothyqiu/rtl-break
git bisect good 0d68db1b85ea4b4dcce3ba46837b868025e9be96
# good: [fed44e3acba1d7f076084fee49ad0f6042eece6f] Merge pull request #42637 from madmiraal/fix-infinite-inertia-3.2
git bisect good fed44e3acba1d7f076084fee49ad0f6042eece6f
# bad: [e6a6293146bcf3f73821369efac06c48e9a2ca47] Merge pull request #49487 from pycbouh/theme-utility-methods-3.x
git bisect bad e6a6293146bcf3f73821369efac06c48e9a2ca47
# good: [fddd09de17d3271fb2c6df0e70640a546ca4cdd5] Fix typo in Control's theme icon look-up method
git bisect good fddd09de17d3271fb2c6df0e70640a546ca4cdd5
# bad: [b622dfa956de2604bf514d8f031ac252477cce1e] Use EditorResourcePicker in the Inspector
git bisect bad b622dfa956de2604bf514d8f031ac252477cce1e
# good: [343ba504d30db1232acbf599c83462d9b76daa05] Add EditorResourcePicker control based on the Inspector editor for Resources
git bisect good 343ba504d30db1232acbf599c83462d9b76daa05
# first bad commit: [b622dfa956de2604bf514d8f031ac252477cce1e] Use EditorResourcePicker in the Inspector

As we discussed with @pycbouh, this is likely related to having a high number of global script classes (class_name) which are slow to parse.

I paused execution with gdb during a lag when drag and dropping a texture with a CPUParticles2D selected, here's how it looks like:

0x0000000001842e5b in GDScriptParser::DataType::DataType (this=0x7ffc1ad75f10) at modules/gdscript/gdscript_parser.h:105
105                                     class_type(nullptr) {}
(gdb) bt
#0  0x0000000001842e5b in GDScriptParser::DataType::DataType (this=0x7ffc1ad75f10) at modules/gdscript/gdscript_parser.h:105
#1  0x00000000018cb596 in GDScriptParser::_reduce_node_type (this=0x7ffc1ad79150, p_node=0x1931a1c0) at modules/gdscript/gdscript_parser.cpp:6373
#2  0x00000000018cc9f3 in GDScriptParser::_reduce_node_type (this=0x7ffc1ad79150, p_node=0x1931a710) at modules/gdscript/gdscript_parser.cpp:6568
#3  0x00000000018ddda0 in GDScriptParser::_check_block_types (this=0x7ffc1ad79150, p_block=0x1931a010) at modules/gdscript/gdscript_parser.cpp:8558
#4  0x00000000018ddf7a in GDScriptParser::_check_block_types (this=0x7ffc1ad79150, p_block=0x19319b60) at modules/gdscript/gdscript_parser.cpp:8584
#5  0x00000000018ddf7a in GDScriptParser::_check_block_types (this=0x7ffc1ad79150, p_block=0x193238e0) at modules/gdscript/gdscript_parser.cpp:8584
#6  0x00000000018ddf7a in GDScriptParser::_check_block_types (this=0x7ffc1ad79150, p_block=0x193234d0) at modules/gdscript/gdscript_parser.cpp:8584
#7  0x00000000018ddf7a in GDScriptParser::_check_block_types (this=0x7ffc1ad79150, p_block=0x19323170) at modules/gdscript/gdscript_parser.cpp:8584
#8  0x00000000018db699 in GDScriptParser::_check_class_blocks_types (this=0x7ffc1ad79150, p_class=0x1932b260) at modules/gdscript/gdscript_parser.cpp:8190
#9  0x00000000018df568 in GDScriptParser::_parse (this=0x7ffc1ad79150, p_base_path=...) at modules/gdscript/gdscript_parser.cpp:8739
#10 0x00000000018dfad9 in GDScriptParser::parse (this=0x7ffc1ad79150, p_code=..., p_base_path=..., p_just_validate=false, p_self_path=..., p_for_completion=false, r_safe_lines=0x0, p_dependencies_only=false)
    at modules/gdscript/gdscript_parser.cpp:8811
#11 0x0000000001811846 in GDScript::reload (this=0x192c1ce0, p_keep_state=false) at modules/gdscript/gdscript.cpp:556
#12 0x000000000181d02a in ResourceFormatLoaderGDScript::load (this=0x8d2c8f0, p_path=..., p_original_path=..., r_error=0x0) at modules/gdscript/gdscript.cpp:2160
#13 0x00000000046020ed in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:262
#14 0x0000000004602c85 in ResourceLoader::load (p_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:376
#15 0x0000000002a78c22 in EditorData::script_class_load_script (this=0x8f7f3d8, p_class=...) at editor/editor_data.cpp:920
#16 0x0000000002a784f5 in EditorData::script_class_is_parent (this=0x8f7f3d8, p_class=..., p_inherits=...) at editor/editor_data.cpp:869
#17 0x0000000002c19eed in EditorResourcePicker::_get_allowed_types (this=0x18eea610, p_with_convert=true, p_vector=0x7ffc1ad798c0) at editor/editor_resource_picker.cpp:475
#18 0x0000000002c1a623 in EditorResourcePicker::_is_drop_valid (this=0x18eea610, p_drag_data=...) at editor/editor_resource_picker.cpp:514
#19 0x0000000002c1df5d in EditorResourcePicker::_notification (this=0x18eea610, p_what=21) at editor/editor_resource_picker.cpp:673
--Type <RET> for more, q to quit, c to continue without paging--
#20 0x0000000002c20f8e in EditorResourcePicker::_notificationv (this=0x18eea610, p_notification=21, p_reversed=false) at editor/editor_resource_picker.h:41
#21 0x00000000043d161b in Object::notification (this=0x18eea610, p_notification=21, p_reversed=false) at core/object.cpp:927
#22 0x000000000355b7cd in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x18eea610, p_what=21) at scene/main/viewport.cpp:1061
#23 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x18ee9f20, p_what=21) at scene/main/viewport.cpp:1067
#24 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x18fdd4c0, p_what=21) at scene/main/viewport.cpp:1067
#25 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x18fdd020, p_what=21) at scene/main/viewport.cpp:1067
#26 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0xb2eae90, p_what=21) at scene/main/viewport.cpp:1067
#27 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0xb2e8870, p_what=21) at scene/main/viewport.cpp:1067
#28 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0xb23f1a0, p_what=21) at scene/main/viewport.cpp:1067
#29 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x96a1a40, p_what=21) at scene/main/viewport.cpp:1067
#30 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x96a15a0, p_what=21) at scene/main/viewport.cpp:1067
#31 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x96a1100, p_what=21) at scene/main/viewport.cpp:1067
#32 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x96a0340, p_what=21) at scene/main/viewport.cpp:1067
#33 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x969f0c0, p_what=21) at scene/main/viewport.cpp:1067
#34 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x969de40, p_what=21) at scene/main/viewport.cpp:1067
#35 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x969d540, p_what=21) at scene/main/viewport.cpp:1067
#36 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x969b5d0, p_what=21) at scene/main/viewport.cpp:1067
#37 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x969b180, p_what=21) at scene/main/viewport.cpp:1067
#38 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x8f7ec80, p_what=21) at scene/main/viewport.cpp:1067
#39 0x000000000355b817 in Viewport::_propagate_viewport_notification (this=0x8f19150, p_node=0x8f19150, p_what=21) at scene/main/viewport.cpp:1067
#40 0x000000000356012f in Viewport::_gui_input_event (this=0x8f19150, p_event=...) at scene/main/viewport.cpp:2106
--Type <RET> for more, q to quit, c to continue without paging--
#41 0x0000000003564233 in Viewport::input (this=0x8f19150, p_event=...) at scene/main/viewport.cpp:2783
#42 0x000000000355d0d2 in Viewport::_vp_input (this=0x8f19150, p_ev=...) at scene/main/viewport.cpp:1401
#43 0x0000000001a45dd3 in MethodBind1<Ref<InputEvent> const&>::call (this=0x87f5d20, p_object=0x8f19150, p_args=0x7ffc1ad7aaf0, p_arg_count=1, r_error=...) at ./core/method_bind.gen.inc:775
#44 0x00000000043d14fe in Object::call (this=0x8f19150, p_method=..., p_args=0x7ffc1ad7aaf0, p_argcount=1, r_error=...) at core/object.cpp:918
#45 0x00000000043d10a9 in Object::call (this=0x8f19150, p_name=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=...) at core/object.cpp:847
#46 0x0000000003531221 in SceneTree::call_group_flags (this=0x87fdf30, p_call_flags=2, p_group=..., p_function=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=...) at scene/main/scene_tree.cpp:270
#47 0x0000000003531ecf in SceneTree::input_event (this=0x87fdf30, p_event=...) at scene/main/scene_tree.cpp:429
#48 0x000000000175cd7b in InputDefault::_parse_input_event_impl (this=0x7a284d0, p_event=..., p_is_emulated=false) at main/input_default.cpp:435
#49 0x000000000175bbf4 in InputDefault::parse_input_event (this=0x7a284d0, p_event=...) at main/input_default.cpp:259
#50 0x000000000175e062 in InputDefault::flush_accumulated_events (this=0x7a284d0) at main/input_default.cpp:652
#51 0x0000000001742926 in OS_X11::process_xevents (this=0x7ffc1ad7b410) at platform/x11/os_x11.cpp:2905
#52 0x00000000017469f5 in OS_X11::run (this=0x7ffc1ad7b410) at platform/x11/os_x11.cpp:3634
#53 0x000000000173482f in main (argc=2, argv=0x7ffc1ad7bd18) at platform/x11/godot_x11.cpp:55

Another manifestation of the issue is that selecting some nodes in the Scene Tree has a noticeable lag (200 ms to 1 s).

@pixel-boy's project that triggers the issue has ~60 global classes.

@akien-mga
Copy link
Member

We figured out a way to reproduce the issue in a minimal project, having plenty of class_name scripts with some code (to force a slow parse of the GDScript) is sufficient. This test is with 300 scripts to make the slowdown very clear:

TestManyGlobalClasses.zip

@YuriSizov
Copy link
Contributor

The linked PR should mitigate the issue. You will still experience a freeze when selecting a new type of node for the first time, but subsequent actions, including drag'n'drop will be smooth. Unfortunately, at this moment it's the only option we have because we need to fetch the information at least once, there is no way around it. Maybe in some feature overhaul this freeze can be later moved to the editor startup instead, but I'd refrain from doing it to fix this as it can have other implications.

@akien-mga akien-mga changed the title Drag and drop and profiler slowdown in the editor since version 3.4.beta2 Drag and drop and node selection slowdown in the editor since version 3.4.beta2 Aug 3, 2021
@akien-mga
Copy link
Member

@pixel-boy In the end the profiler slowdown you seem to experience (which I can't reproduce on my hardware) might be an unrelated issue, so it would be good if you can file a new issue about it with details on your hardware (and the fact that you can't reproduce it on another machine as you told me in DM).

@akien-mga
Copy link
Member

Fixed by #51211.

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

No branches or pull requests

4 participants