ng-idle
ng-idle copied to clipboard
Performance - too many digest cycles triggered
It seems that for some reason ng-idle is triggering too many AngularJS digest
cycles.
This cause performance issues on big applications, especially when a lot of non trivial AngularJS filters are used (filters are evaluated at every digest cycle).
repro:
- open the ng-idle demo website (http://hackedbychinese.github.io/ng-idle/)
- start the demo
- quickly move the mouse around for 2-3 seconds
The browser cpu usage goes up (5% on a Intel i7 pc, much more on less powerful machines).
Moving the mouse without starting the demo doesn't cause any significant CPU usage.
By default, ng-idle registers for the following events: mousemove keydown DOMMouseScroll mousewheel mousedown touchstart touchmove scroll.
Especially mousemove and scroll lead to high-frequency creation of events when mouse is moved or screen is scrolled. If you don't ultimately need this, remove the two events, and maybe also DOMMouseScroll. This likely reduces the frequency in which the ng-idle's listener is called dramatically.
One change I implemented in ng2-idle was to just throttle interrupt calls, 1 per second would likely do the trick.
@HackedByChinese Where can I change this setting to angularjs?