-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Slow ng-repeat because of AnimateRunner even without ngAnimate #14066
Comments
Which version of Angular is this? |
Why does this function exist? |
The profile also doesn't really show that the slowness is "caused by AnimateRunner and nothing else." |
Why animation event listeners must be run when ngAnimate is not included? |
The event listeners / callbacks should fire even when no actual animations run. This can be important for example if you are testing your application without animations. Then you would still want the resilts of the callbacks that fire when the animation is complete. |
@Narretz This is with version 1.5, running in an electron browser window (chromium). I will complete more meaningful testing once I get into the office later today. |
@Narretz Thanks for the explanation. |
@Narretz, do we really need the RAFs without |
The large majority of the computation time is spent checking whether the element should have animations applied to it. Unfortunately this occurs even if we don't have any animations... I'll try to make some improvements. |
Can you elaborate? Which code does that? Please be specific if you mean the code with the ngAnimate module as a dependency or without it. @gkalpak I'm not sure if the rAF is needed, but it definitely enforces asyncronicity, which is possibly what we want for consistency. @frfancha Different example: you are using a 3rd party module that uses $animate and also an animation callback that is important. If you are now disabling ngAnimate from your app you would expect the DOM operations and the callback to work as before. |
@Narretz After some further investigation I've identified the issue with a high count of redundant calls to retrieve the It is especially noticeable when using angular in electron because electron will make a quick ipc call to it's main thread to retrieve whether the document is hidden. This call is quick, but synchronous as it's integrated to getting the One might argue that this is an issue with electron, but I would disagree. TL;DR it is unnecessary to make calls for document.window thousands of times in the span of a second for the rare case when the document is hidden. Stats Interested to hear your thoughts on how the redundant calls should be avoided. |
@ArekSredzki and I'm interested in your thoughts :) Thanks for investigating. We could maybe cache the hidden value, but the question is in which time period. Another option would be to listen to the events that are emitted when a document is hidden or shown. |
@Narretz Thanks :) https://developer.mozilla.org/en-US/docs/Web/Events/visibilitychange is exactly what we need. I'm not familiar with angular's inner workings, does it have a stateful module where we could keep this value? |
We can keep it in a provider. I'm working on a Pr. |
@Narretz Great! Excited to check it out once it's ready. |
Accessing the document for the hidden state is costly for platforms like Electron. Closes angular#14066
Accessing the document for the hidden state is costly for platforms like Electron. Closes angular#14066
Accessing the document for the hidden state is costly for platforms like Electron. Closes angular#14066
Accessing the document for the hidden state is costly for platforms like Electron. Closes angular#14066
perf(ngAnimate): listen for document visibility changes Accessing the document for the hidden state is costly for platforms like Electron. Instead, listen for visibilitychange and store the state. (angular#14071) Closes angular#14066
perf(ngAnimate): listen for document visibility changes Accessing the document for the hidden state is costly for platforms like Electron. Instead, listen for visibilitychange and store the state. (angular#14071) Closes angular#14066
Accessing the document for the hidden state is costly for platforms like Electron. Instead, listen for visibilitychange and store the state. Closes angular#14066
Accessing the document for the hidden state is costly for platforms like Electron. Instead, listen for visibilitychange and store the state. Closes angular#14066
Accessing the document for the hidden state is costly for platforms like Electron. Instead, listen for visibilitychange and store the state. Closes #14066
I'm trying to print a lot of elements to the DOM, but it is painfully slow.
However, the reason is caused by AnimateRunner and nothing else.
Note: I do not want to filter the elements further, but rather get to the bottom of why an un-needed component is stalling the entire browser
I have disabled ngAnimate, the page has no animations, yet the slowest part of the whole process is it's complete function.
Please see the profile below

Your suggestions are greatly appreciated.
The text was updated successfully, but these errors were encountered: