-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Performance issue: modals & popups #6882
Comments
Seems related to #6713. |
@crisbeto Ok, you now have a way to reproduce it, do you have any ETA for a fix? |
The exact same problem here. |
@giacomocerquone It seems to be an angular bug related to event listeners. They said it's fixed, the fix will land on ng5, probably even sooner in ng4.4. |
@crisbeto You should really do something about the plunkers, It takes time to code them and they always break within a few days. Should I open an issue for this? |
@Ploppy3 Wooa, this is a great news actually! Thank you very much 😄 |
@crisbeto True about the plunkers! I can tell you that it is always like that, every plunker I find online is somehow broken |
@giacomocerquone Unfortunately it did not ship in 4.4.x. |
@Ploppy3 Yes but my point is, why this package for the modal works? https://github.com/dougludlow/ng2-bs3-modal I mean, wouldn't it be better to implement the modal like that? |
* Removes the global scroll listener from the viewport ruler, which was being used to invalidate the scroll position cache. Caching the scroll position is pointless since it'll be invalidated very frequently. Since most Material components depend on the `ViewportRuler` one way or another, it meant that there was a good chance that the scroll listener would stay around forever. * Fixes an issue that caused the scroll dispatcher not to remove its global scroll listener, if there are any scrollables on the page, even though nothing was subscribed to it. Fixes angular#6882.
* Removes the global scroll listener from the viewport ruler, which was being used to invalidate the scroll position cache. Caching the scroll position is pointless since it'll be invalidated very frequently. Since most Material components depend on the `ViewportRuler` one way or another, it meant that there was a good chance that the scroll listener would stay around forever. * Fixes an issue that caused the scroll dispatcher not to remove its global scroll listener, if there are any scrollables on the page, even though nothing was subscribed to it. Fixes angular#6882.
* Removes the global scroll listener from the viewport ruler, which was being used to invalidate the scroll position cache. Caching the scroll position is pointless since it'll be invalidated very frequently. Since most Material components depend on the `ViewportRuler` one way or another, it meant that there was a good chance that the scroll listener would stay around forever. * Fixes an issue that caused the scroll dispatcher not to remove its global scroll listener, if there are any scrollables on the page, even though nothing was subscribed to it. Fixes angular#6882.
* Removes the global scroll listener from the viewport ruler, which was being used to invalidate the scroll position cache. Caching the scroll position is pointless since it'll be invalidated very frequently. Since most Material components depend on the `ViewportRuler` one way or another, it meant that there was a good chance that the scroll listener would stay around forever. * Fixes an issue that caused the scroll dispatcher not to remove its global scroll listener, if there are any scrollables on the page, even though nothing was subscribed to it. Fixes #6882.
@crisbeto Hello, I'm confused, I was told the issue was solved on the Angular side but you implemented your own fix for it. Or is it just some perf improvements? Also I don't wanna open an issue for this and I'm pretty sure you are aware that Angular 5 is incompatible with Material, when should we expect a compatible version to be released? |
There were a couple of components to the issue:
As for Angular 5 support, it'll be available when Angular 5 stable is released. |
Thank you very much for your work, when will be available this fix in material? |
@crisbeto Not fixed, reopen if you agree. Tested on [email protected] with angular/[email protected] |
That was my best guess based on known performance issues @Ploppy3, it's hard to investigate without an example of something that is considered "slow". |
@crisbeto That's why I created the plunker, so that you can all see the problem, it's here, that's for sure. I don't know how Angular/material works so I can't help much but the problem is related. I realized something new, scrolling slowly (if you remember how the plunker worked) doesn't break performance. BTW I tried to create a stackblitz to replace the plunker. |
@crisbeto Ok, found something even better: removing the cdk-overlay-container from dom in chrome dev tools fixes the problem, so it's in fact the overlay container causing a problem, as expected. But if by simply removing it it fixes the problem, does it mean it's caused by a listener on it? Performance hit seen by chrome: |
@crisbeto Can you please reopen? Thank you. Edit, even more investigation:
This is the best I can do so far to help identify the problem. |
Regarding "Closing menu does not remove cdk-overlay-0 from DOM, something is wrong at this point" this works as expected, the overlay will be removed when you navigate to a new route. |
First of all here's a working Plunkr for reference: http://plnkr.co/edit/QFl2PT?p=preview. Second, I really don't see a difference when comparing scrolling before opening the menu and after. Third, there a lot of other things in your code that can be performance bottlenecks:
|
First, Thank you for the plunker. cdk-overlay-0 is removed from DOM after scrolling stutters (this issue), not only after navigating to a new route. If you wanna see the stutter: don't "swipe-hold" but "swipe and let-go" (like throwing the list away, so that it keeps scrolling without you touching it, not sure how to explain this properly), you will obviously see it, tested by friends and on many devices/browsers, so it's a fact not something that I'm imagining :'( . Something caused by the overlay stops the scrolling somehow and As I said simply removing the I'm not familiar with |
@crisbeto Well, I found what the causing the problem. By mocking a It is related to Though I have no idea why this would be incompatible with my code. Any idea? |
@Ploppy3 FWIW making the overlay-container's height 0 does seem to return to initial behavior. I don't know about the root issue, but you might get away with overriding the css to keep its height at 0 and setting |
@willshowell But I use the overlay, I can't just move it away or hide it. |
It works properly on Firefox, couldn't test on IE 11 because Angular 5 or Material 5rc0 is incompatible with it. It also works on Edge. May I ask you ( @crisbeto ) why not remove the |
Sorry for the delay, but I was away the past few days. @Ploppy3 I'm still having a hard time seeing any difference in performance between toggling the |
@crisbeto No problem. I can try to explain it one more time differently but I'm running out of idea. Try holding the middle mouse button and move the mouse up or down to scroll. The scroll will stop randomly once the |
I definitely see what you mean, but I don't think it's something that applies to all scrolling. Here's a forked Plunkr where I replaced the virtual scrolling with a regular scrollable div and I don't see the issue anymore. |
Yeah, it does not apply to all scrolling, but if it happened to me it will happen to others. I do understand that it seems like a localized issue and is not related to @angular/material especially but I don't have the knowledge on Chrome nor Angular to go more in-depth an see what is causing it, I'm not even sure if this will be fixed one day. What I do know is that my code, despite not being really great, should work properly. I would really like it to be fixed and despite not knowing how Material works internally, I think that the easiest way to do it right now is to hide the overlay when it is unused with |
I'll check if we can do it safely without any regressions, but even then it may be a while until it makes it into a release. Meanwhile it should be pretty safe to add something like this to your CSS: .cdk-overlay-container {
width: auto;
height: auto;
}
.cdk-overlay-backdrop {
position: fixed;
} |
@crisbeto Thank you very much! This slightly modified version did the trick:
|
@crisbeto By using a custom scroll event listener I managed to run most the logic outside of angular zone, only the template's update triggers an angular check. |
Hides the `.cdk-overlay-container` if it doesn't have any attached overlays. This prevents the browser from rendering it as a transparent overlay. Fixes angular#6882. Fixes angular#10033.
@crisbeto Thank you very much for your hard work 👍 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Bug
What is the expected behavior?
There should be no performance hit when using popups and modals
What is the current behavior?
There is a performance hit when using popups and modals
What are the steps to reproduce?
http://plnkr.co/edit/OeUkGO1w4suNVLCQceEL
What is the use-case or motivation for changing an existing behavior?
Angular Material has several performance issues which I think should be addressed.
The web is already slow, no need to make it any slower.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
@angular/material: ^2.0.0-beta.10
Chrome 61
Is there anything else we should know?
There is a big performance problem related to the modals & popups, I can't figure out what it is. You can often see that animations are slightly stuttering on any device & chrome version after you open a modal/popup. The performance often goes back to it's normal state after a while and sometimes don't which is a real problem, on lower-end device this performance hit is NOT negligible at all.
This bug was probably introduced when the popup/modal system was added which is quite old.
The text was updated successfully, but these errors were encountered: