Hi!
I have an issue with the tutorial omni.example.ui_scene.object_info
(kit-extension-sample-ui-scene/exts/omni.example.ui_scene.object_info at main · NVIDIA-Omniverse/kit-extension-sample-ui-scene · GitHub ).
I wanted to use this extension as a starting point to create a similar extension with values that change in real time but also with potentially the content of the widget changing (adding text, values, images, etc). The problem is, after a while, the application slows down a lot. If I put a counter, I notice that this is after a hundred rebuilds of the widget.
To recreate a minimal version of the problem by starting from the extension omni.example.ui_scene.object_info
and change:
-
In the class
WidgetInfoManipulator
inon_bluid
the line :
self._widget = sc.Widget(500, 150, update_policy=sc.Widget.UpdatePolicy.ON_HOVERED)
byself._widget = sc.Widget(500, 150, update_policy=sc.Widget.UpdatePolicy.ALWAYS)
. -
In the class
WidgetInfoManipulator
inon_model_updated
add at the end, the line :
self._widget.frame.rebuild()
. -
In the class
WidgetInfoModel
in__init__
, add at the end, the lines:
self.__viewport_api = vp_utils.get_active_viewport_window().viewport_api
andself.__frame_changed_sub = self.__viewport_api.subscribe_to_frame_change(self.update_model_state)
. -
In the class
WidgetInfoManipulator
creates the functionupdate_model_state
:
def update_model_state(self, _):
self._item_changed(None)
Moreover, as soon as I restart the extension, the application becomes fluid again (the number of FPS increases) and as soon as I activate the rebuild of the widget every frame, the number of FPS decreases dramatically.
After some tests, I think it’s not because I rebuild the frame at each update (i.e. self._widget.frame.rebuild()
), but rather because I rebuild the widget each time with the update_policy=sc.Widget.UpdatePolicy.ALWAYS
option.
Thanks a lot!
Félix