Replies: 2 comments 6 replies
-
I've seen that message too. Was wondering the same thing. Haven't noticed ui slowdown, but haven't paid attention either. Will check next time. |
Beta Was this translation helpful? Give feedback.
-
Hi @eponymic, let me try to explain: It looks like your app is using binding to update UI elements automatically. NiceGUI's binding module holds a collection of bindings, which are basically pairs of source and target objects. Since one object can bind to another, which binds to a third object, a binding network emerges. And if a single value changes, it has to propagate through the network. Now there are two types of bindings:
The "bindable properties" are very efficient and don't cost anything as long as the values don't change. But the "active links" need to check all bound values 10 times per second. This can get costly, especially if you bind to complex objects like lists or dictionaries. Because it is crucial not to block the main thread for too long, we show a warning if one step of the Let's look into the shear number of bindings in your case: 281,304 active links seem to be way too many. And since the number is increasing, it looks like you're generating more and more UI elements (or other objects?) that are never removed. This could be, e.g., dialogs or menus that are created in a timer but never opened. I'd recommend removing parts of your UI and watching how the binding and element count behaves: from nicegui import binding, context, ui
ui.timer(1.0, lambda: (
print('elements:', len(context.get_client().elements)),
print('bindings:', len(binding.bindings)),
print('a. links:', len(binding.active_links)),
print('b. props:', len(binding.bindable_properties)),
)) As a side note: In case you're binding against collections, you can also use the (currently undocumented) from nicegui import observables
persons = observables.ObservableList(['John', 'Jane', 'Joe'], on_change=lambda _: print('persons changed')) |
Beta Was this translation helpful? Give feedback.
-
Question
binding propagation for 281304 active links took 0.692 s
My application is long running and is run from Supervisor. After some period of time, I don't know exactly how long, I see this message repeatedly in the Supervisor log. The number '281304' goes up and up. Does anyone know what this is? I've tried searching the discussion board here and Google. In case it's a clue, I've also noticed the hamburger menu button responds slowly during this time (could be coincidence)
Beta Was this translation helpful? Give feedback.
All reactions