gazebosim / gz-gui

Builds on top of Qt to provide widgets which are useful when developing robotics applications, such as a 3D view, plots, dashboard, etc, and can be used together in a convenient unified interface.
https://gazebosim.org
Apache License 2.0
76 stars 44 forks source link

Slow widget creation in TopicInterface plugin #26

Closed osrf-migration closed 6 years ago

osrf-migration commented 6 years ago

Original report (archived issue) by Carlos Agüero (Bitbucket: caguero, GitHub: caguero).


I'm a publishing an Ignition.msgs.Scene message with a few models and links. It takes more than 10+ seconds to load all the fields in the TopicInterface plugin. My preliminary profiling points to MessageWidget::Parse().

Here's how to reproduce it:

Terminal 1:

#!c++

caguero@flaco:~/delphyne_ws/src/ign_gui$ ign gui -c examples/config/topicInterface.config

Terminal 2: Paste the content of this snippet.

osrf-migration commented 6 years ago

Original comment by Carlos Agüero (Bitbucket: caguero, GitHub: caguero).


osrf-migration commented 6 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


I looked a bit into this. Indeed, in my system, your message is taking about 18 seconds to be initialized, and during this time the UI is frozen.

Future updates to the UI are much quicker though, changing a field's value or adding / removing a nested message takes less than 30 ms. To me, this suggests the bottleneck is not the message parsing, which also happens for every update, but the widget creation.

My first idea would be to move the widget creation to another thread, and only do the actual adding of it to the window on the main thread. This wouldn't solve the delay problem, but at least the UI should not be frozen.

Need to investigate more to figure out if there's anything specifically bad we're doing when generating the widgets.

osrf-migration commented 6 years ago

Original comment by Carlos Agüero (Bitbucket: caguero, GitHub: caguero).


That sounds a good plan.

osrf-migration commented 6 years ago

Original comment by Carlos Agüero (Bitbucket: caguero, GitHub: caguero).


We've been recently discussing about this issue. If we cannot improve the performance of Parse() on widget creation, we could also try to create the widget only when the user clicks to expand a given level of the tree widget. This could also happen asynchronously in a different thread. This way we don't have to load all widgets in a single shot, it will happen sequentially as the user continues expanding more branches of the scene tree widget.

osrf-migration commented 6 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


That a great idea, I'm working on an implementation of it now

osrf-migration commented 6 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


See pull request #106

osrf-migration commented 6 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).