Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digest cycles initiated by the grid #5007

Open
YonatanKra opened this issue Jan 21, 2016 · 3 comments
Open

Digest cycles initiated by the grid #5007

YonatanKra opened this issue Jan 21, 2016 · 3 comments

Comments

@YonatanKra
Copy link
Contributor

There are way too many digest cycles for the grid load/rendering. I've managed to reduce the load by setting some of the $timeouts to $timeout(method, 0, false). I've managed to reduce the number by 2/3 this way, with no seeming side effects (and my app now loads much faster - I have around 9-10 grids on one page, that can open side menus with more, so this is critical...).

I've created a plnkr that shows that every load, you get roughly 35 digest cycles - with no extra feature involved:
http://plnkr.co/edit/uOYKeJvANJu1b9zk8Ac1?p=catalogue (it also shows that the grid increases the number of digests each time it reloads which might indicate a memory leak, but then again, it might be just the demo app).

For instnace:


init is being called iniside a $timeout. It then calls grid.refreshCanvas which in turn does another $timeout (
$timeout(function() {
), hence calleing twich to a digest cycle...

As I said, I've managed to reduce this number of cycles with the method above. Is there a special reason why there are so many $timeouts inside the core code?

@swalters
Copy link
Contributor

If all the unit tests work and all of the tutorials work, then I see nothing but positives for this change. You want to submit a PR?

csvan added a commit to csvan/ui-grid that referenced this issue Nov 23, 2016
Angular's $timeout takes a boolean 3rd parameter which
causes the wrapped function to not run inside $apply.
Since $timeout is used extensively in scope, this parameter
has been passed where possible in order to improve
performance, since the grid otherwise triggers a large
number of digests while functioning normally.

See issue: angular-ui#5007
@csvan
Copy link
Contributor

csvan commented Nov 23, 2016

Made a PR for this: #5829

Ping @swalters

@csvan
Copy link
Contributor

csvan commented Dec 5, 2016

@YonatanKra #5829 just got merged, if you are happy with the changes maybe this can be closed.

mportuga pushed a commit that referenced this issue Mar 22, 2017
Part 1: Reduce digest cylces in ui-grid-utils

#5007
mportuga pushed a commit that referenced this issue Mar 22, 2017
vishalnarewade pushed a commit to vishalnarewade/ui-grid that referenced this issue Nov 6, 2017
vishalnarewade pushed a commit to vishalnarewade/ui-grid that referenced this issue Nov 6, 2017
@mportuga mportuga added this to High priority in Bug Triage Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Bug Triage
  
High priority
Development

No branches or pull requests

4 participants