You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Performance] ScrollDispatcher should subscribe lazily, and destroy subscriptions when they are no longer used #3237
ScrollDispatcher needs to create subscriptions to the window scroll/resize events lazily (when they are actually needed by the UI) and destroy them once the UI using them gets destroyed.
Currently it simply subscribes to the scroll and resize events on init, which is when the page loads.
Since it is not utilizing the zone.runOutsideAngular functionality, then it means that every time a scroll or resize event happens, it will re-render the UI several times.
This usually goes unnoticed in smaller applications, but when you have bigger applications, this slows down the UI a lot.
It also removes performance control from the developers.
It's fine to emit the events when the dispatcher is actually being used by an overlay or whatnot, but it makes no sense to trigger zone to re-render the view every time the user scrolls, when there's nothing new to re-render.
I'd suggest making the subscriptions lazy and destroy them when components unsubscribe, or if possible using the zone.runOutsideAngular functionality to never trigger a re-render in the first place.
version 2.0.0-beta.2
Reacted by Aleš, Alexander Ciesielski, Quentin and PritulaRoman
Activity
fxck commentedon Feb 22, 2017
I swear I saw a PR dealing with this already but can't seem to be able to find it now.. if not, this seems like a pretty big issue.
@andrewseguin @crisbeto ?
kara commentedon Feb 22, 2017
Related to #3179.
perf(scroll-dispatcher): lazily subscribe to global events
perf(scroll-dispatcher): lazily subscribe to global events (#3270)
sync from upstream (#1)
angular-automatic-lock-bot commentedon Sep 5, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.