[Tooltip] Rendering many tooltips is slow
Hello, I just wanted to report that using mdTooltip too much seems to slow down rendering time of my Angular app by a lot compared to adding many other components or *ngIfs.
I had a table that make
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
At least Chrome
Can you provide a plunker example?
Here's a plunker, but in the plunker it's fast. Yet in my project, I double checked again simply adding an mdTooltip="0" attribute is slowing it way down. I can't tell if the plunker is using the latest Angular / Material code. Is there an up-to-date starter plunker with Angular Material already set up?
https://plnkr.co/edit/HtEUoZ28ti3xILgxpyFJ?p=info
Ok, updated the plunker, please see previous message. (I made a mistake and timed the same thing twice.)
In my browser, 1000 ngIfs renders in 50-90ms, whereas 1000 mdTooltips renders in 390-450ms.
I see it... but I don't think it's so unexpected. Not sure, but suposing the mdTooltip is based on mousein and mouseout events, it has to register them. Registering an event is a considerable time consuming task (and you're doing it a lot in the plunker).
To see the if component rendering time increase two times the actual value in your plunker, just register a click event in the <span>: (click)="compute(2)". Over here, it jumps from 63ms to 140ms just because of this. With two event handlers, it jumps to 225ms.
But I think the material guys will give you a more accurate answer. I don't know if it could be possible to do something like a lazy event registering (immediatly after the component is rendered). It would give the final user a better experience.
I heard Angular is now using native addEventListner for better performance.
However now it seems even slower, taking over 600ms to render 1000 tooltips, and each time I click it goes slower and slower.
Updated plunker since the old one stopped working: https://plnkr.co/edit/q3w43vEFOQukzWuuRGJb?p=preview
Just encountered this issue while adding matTooltips to large arrays of data
Here is a simplified version in a stackblitz, it will initially load a little slow but not too bad, uncommenting lines 14 and 17 in app.component.ts will make it significantly slower:
https://stackblitz.com/edit/angular-4x8ama?file=app%2Fapp.component.ts
I get this lag too. If on of my function (even parent) have a console.log I see it's output on EVERY mosemove on tooltip of any (even child) components
I get this too. Say I have 20 blocks, which has header block which contains 2 div with tooltips (each div).
When I reduced to 1 for each header block, the performance noticeably improved...
same here... We cannot use mat-tooltips...
Hello,
I know the issue is old, but I'm having the same issue with Angular Material ^8.0.0.
The guys in my team found a work around by using SVG : create ONE custom tooltip and moving it on the hovered element (with a mess of absolute x and y calculation).
@CNicolas, you can try https://github.com/ncstate-sat/popover. It's very flexible, based on cdkOverlay and you can have just one instance (and anchors all over de place).
Thank you @julianobrasil, it worked perfectly !
There have been a handful of perf improvements for tooltips since this was opened: https://github.com/angular/components/pulls?q=is%3Apr+tooltip+is%3Aclosed+perf
Going to close, but feel free to open a new issue if anyone has an example of excessive perf cost.
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.