ng-idle icon indicating copy to clipboard operation
ng-idle copied to clipboard

Performance - too many digest cycles triggered

Open webartoli opened this issue 8 years ago • 3 comments

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.

webartoli avatar Feb 19 '16 11:02 webartoli

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.

twwwt avatar Apr 11 '16 11:04 twwwt

One change I implemented in ng2-idle was to just throttle interrupt calls, 1 per second would likely do the trick.

moribvndvs avatar Apr 11 '16 16:04 moribvndvs

@HackedByChinese Where can I change this setting to angularjs?

GlauberF avatar May 16 '17 14:05 GlauberF