(perf) md-tooltip triggers digest cycles on scroll
In the latest (1.0.1) it seems that md-tooltip is very greedy about scroll event - basically any scroll on page is triggering digest cycle (no throttling etc. = a lot of digests!). At the moment we disabled tooltips because of that but in my opinion this needs to be addressed.
Here is a very simple codepen based on md-tooltip demo page. http://codepen.io/anon/pen/rxyJaZ
I added small vanilla JS counter that is triggered whenever my watcher function is triggered. You can see that any scroll on the page creates whole lot of digests. It does seem that tooltip is using runs "setVisible(false)" https://github.com/angular/material/blob/master/src/components/tooltip/tooltip.js#L150
And it uses "$mdUtil.nextTick" to set "scope.visible = false;" so that it coalesces calls. Unfortunately it seems it is not enough for desktop browser scroll (this is tested on OSX) and processQueue is called multiple times per scroll. Maybe some kind of debounced function as windowScroll would be better here?
BTW. maybe check if tooltip is currently visible/hidden and not trigger digest at all when setVisible is called with same value as current?
like https://github.com/angular/material/blob/master/src/components/tooltip/tooltip.js#L190 :
if(scope.visible === !!value) {
return;
}
?
We need additional check if the value is queued.
if ((setVisible.queued && setVisible.visible === !!value) || (!setVisible.queued && scope.visible === !!value)) {
return;
}
closed with 65239b7