Open gibrilhamideh opened 4 months ago
i think i figured out whats going on
from kivymd.uix.behaviors import HoverBehavior
kivymd 2.0.1.dev is binding to "Window.bind(mouse_pos=self.on_mouse_update)" through the class "StateLayerBehavior" for all the following widgets
MDCard, MDLabel MDIcon MDTextField, MDIconButton, MDButton, MDFabButton, MDExtendedFabButton, MDChip, MDSwitch, MDCheckbox, BaseListItem, MDTabsItemBase
so just by hovering the mouse will fire self.on_mouse_update for thousands of widgets if the application is large and will cause a lag.
recommended solution:
i think by settings a parameter of example hover_behavior = BooleanProperty() for all the previous mentions classes, the user can decide what widget can have the hover effect
and more effeciant widgets, for example MDListItem can have 3 MDLabels 2 MDIcons and they all all bind to "on_mouse_update" through inherting from StateLayerBehavior, so only one widget will fire 6 events per mouse move per pixel, imagine having 1000 widgets, that will cause a lot of delay
@gibrilhamideh Thanks for the analysis! This makes it easier to localize and fix this bug.
No problem, anytime!
* OS: unbuntu 20.04
* Python: python 3.11
* Kivy: 2.3.0
* KivyMD: 2.0.1.dev
problem:
trying to scroll view through MDListItems with the mouse wheel with moving my mouse causing a major lag,
but scrolling with the mouse wheel with out hovering my mouse does not lag.
explination:
i know real life application doesn't create 800 MDListItems i just put that much widgets to magnify the problem
the application i am working on is 42 screens and switching from kivymd 1.2.0.dev to 2.0.1.dev, you can see the effect on my #application dramatically, causing it to lag alot.