godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix slow import when window is unfocused

Open Hilderin opened this issue 1 year ago • 4 comments

Fixes #93877

Effectively, the importation speed was dependent on the VSync and Update continuously settings. That was because there is a lot of progress popup update while importing scenes. Disabling VSync and Update continuously settings while importing files accelerated the importation process on my computer and I got the same speed now when the editor is focused or not. On my computer, it accelerated the importation of the MRP project from 132 sec. to 88 sec. even when focused.

At the same time, I made a couple of little tweaks in the progress popups to prevent redrawing at each step progress passing p_force_redraw to false to step method. There was also a bug in ProgressDialog when more then one step was present. If the second task was updated quickly or with p_force_redraw at true, the first step was never updated if the first task was using p_force_redraw at false. That was because last_progress_tick was global and always updated only for the second task. When task_step was called for the first task, last_progress_tick was always up to date causing it to return and not update the step.

Hilderin avatar Jul 04 '24 19:07 Hilderin

Yes, I think it's because of Main::iteration(). When VSync is enabled, the DisplayServer waits before rendering the frame (I think) and with low_processor_usage_mode, OS::add_frame_delay adds low_processor_usage_mode_sleep_usec each frame.

Hilderin avatar Jul 04 '24 21:07 Hilderin

Thanks for testing. I'm glad that you are able to get the same performance has the "optional settings". For the difference in the time for the importation, I took a quick look at all the modifications between https://github.com/godotengine/godot/commit/92c8e87cd987e8d55d176608c3038e9c4646cb2c and https://github.com/godotengine/godot/commit/4d984b63697d840f2c823608d2c46740fb44651a https://github.com/godotengine/godot/compare/92c8e87..4d984b6

The only thing I see that could have affected the importation is that commit which was suppose to optimize the load/saving of scenes: https://github.com/godotengine/godot/commit/b83c64faacd317bd375b90b5f24cfd62cf72d96c (#93723)

I don't known, maybe it reloads all the meshes to load scene groups?!? I could look into it a bit later.

Hilderin avatar Jul 07 '24 03:07 Hilderin

I don't known, maybe it reloads all the meshes to load scene groups?!? I could look into it a bit later.

After testing 4.3.beta2, 4.3.dev2 and 4.2.2, I can't reproduce my time of 12 seconds with any of their official builds (or my self-compiled build of 92c8e87cd). I'm not sure how I managed to get that time in the first place. If anything, the latest master branch is a bit faster than 4.2.2.

Calinou avatar Jul 07 '24 03:07 Calinou

That's a good news!!! I'll not investigate further then. Thanks!

Hilderin avatar Jul 07 '24 03:07 Hilderin

Needs rebase, then it should be good to merge.

akien-mga avatar Aug 27 '24 21:08 akien-mga

Rebased done! I retested with the MRP project from the issue. Performance optimization was as expected.

Hilderin avatar Aug 28 '24 00:08 Hilderin

Thanks!

akien-mga avatar Aug 28 '24 08:08 akien-mga