mui-org/material-ui

What the will-change issue might be? #10831

leedstyh posted onGitHub

<!--- Provide a general summary of the issue in the Title above -->

<!-- Thank you very much for contributing to Material-UI by creating an issue! ❤️ To avoid duplicate issues we ask you to check off the following list. -->

<!-- Checked checkbox should look like this: [x] -->

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

<!--- If you're describing a bug, tell us what should happen. If you're suggesting a change/improvement, tell us how it should work. -->

No warning message

Current Behavior

<!--- If describing a bug, tell us what happens instead of the expected behavior. If suggesting a change/improvement, explain the difference from current behavior. -->

I got this warning in my Firefox Will-change memory consumption is too high. Budget limit is the document surface area multiplied by 3 (1047673 px). Occurrences of will-change over the budget will be ignored.

I googled it that will-change seems like a css thing, so I searched MUI code base, found that some Components used this. And I'm using Fade and LinearProgress in my app.

So what might be the problem with them, and how to avoid this warning?

Is this warning serious?

Steps to Reproduce (for bugs)

<!--- Provide a link to a live example (you can use codesandbox.io) and an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant (which it most likely is). This codesandbox.io template may be a good starting point: https://codesandbox.io/s/github/mui-org/material-ui/tree/v1-beta/examples/create-react-app If YOU DO NOT take time to provide a codesandbox.io reproduction, should the COMMUNITY take time to help you? -->

1. 2. 3. 4.

Context

<!--- How has this issue affected you? What are you trying to accomplish? Providing context helps us come up with a solution that is most useful in the real world. -->

Seems like not a serious issue

Your Environment

<!--- Include as many relevant details about the environment with which you experienced the bug. -->

Tech Version
Material-UI 1.0.0-beta.37
React 16.3.0-alpha.2
browser Firefox 60 on windows 10
etc

@leedstyh We don't use the willChange property much: https://github.com/mui-org/material-ui/search?utf8=%E2%9C%93&q=willchange&type=. Can you provide a isolated reproduction example? The warning could come from a third party library.

posted by oliviertassinari about 7 years ago

Not appears every time, so I'll close this now. Will ping you back here if I have more details. Thanks @oliviertassinari

posted by leedstyh about 7 years ago

Hi @oliviertassinari

I've just encountered this warning.

Thanks for your efforts in keeping MUI performant!

I see that the MDN documentation has this prominent note:

Important: will-change is intended to be used as a last resort, in order to try to deal with existing performance problems. It should not be used to anticipate performance problems.

And further down provides a lengthy list of advice against using this property, including warning against premature optimisation.

Given these warnings, should this property be removed?

posted by avdd over 6 years ago

@avdd What makes you think it's coming from Material-UI?

posted by oliviertassinari over 6 years ago

Budget limit is the document surface area multiplied by 3

@avdd Why does it cover 3 times the surface area?

posted by oliviertassinari over 6 years ago

@oliviertassinari I think that's just firefox reporting how much memory it's allocating for this optimisation.

My point is, MDN suggests that will-change is an expensive optimisation and should only be used as a "last resort". I was wondering if it's appropriate for MUI to use this expensive optimisation at all. Do you think that it should be the app developer's decision instead?

posted by avdd over 6 years ago

Again, please check why you are covering 3 times the surface area. A single component shouldn't cover more than 1 time the surface area.

posted by oliviertassinari over 6 years ago

@oliviertassinari that number is a firefox implementation detail and nothing to do with my code:

https://dxr.mozilla.org/mozilla-central/source/layout/painting/nsDisplayList.cpp#2052

posted by avdd over 6 years ago

@oliviertassinari you weren't even quoting me! 🙂

Fortunately, your good design means I can somewhat easily turn this property off for my application by overriding the style for Backdrop.

But my point is, from my reading of MDN and other sources, that I probably shouldn't have to do that.

Important: will-change is intended to be used as a last resort, in order to try to deal with existing performance problems. It should not be used to anticipate performance problems. ... Don't apply will-change to elements to perform premature optimization.

So, is this a premature optimization? Was there an existing performance problem that this property solves? If not, then it would be fair to interpret that MDN is explicitly warning against precisely this usage, which is why firefox is generating the warning.

And not only MDN.

https://www.w3.org/TR/css-will-change-1/#using

Using will-change directly in a stylesheet implies that the targeted elements are always a few moments away from changing. This is usually not what you actually mean; instead, will-change should usually be flipped on and off via scripting before and after the change occurs

https://dev.opera.com/articles/css-will-change-property/

You see, the browser does already try to optimize for everything as much as it can (remember opacity and 3D transforms?), so explicitly telling it to do that doesn’t really change anything or help in any way. As a matter of fact, doing this has the capacity to do a lot of harm, because some of the stronger optimizations that are likely to be tied to will-change end up using a lot of a machine’s resources, and when overused like this can cause the page to slow down or even crash.

In other words, putting the browser on guard for changes that may or may not occur is a bad idea, and will do more harm that good. Don’t do it.

https://www.sitepoint.com/introduction-css-will-change-property/

Always remember to remove the will-change property when you’re finished using it. As I mentioned above, browser optimizations are a costly process and so when used poorly they can have adverse effects.

My interpretation is that, sans a thorough performance test suite with a specific hardware matrix (as the roadmap says, "we can’t optimize something we can’t measure"), a library has no place using will-change at all.

Again because of your good design, if there is an actual performance problem, an application developer can easily add this property in a targeted optimisation.

Finally, of course, thanks again for your fine work! đź‘Ť

posted by avdd over 6 years ago

@avdd Alright. Do you want to remove the usage of this property? Right now, it only makes sense for the LinearProgress component. The other usage occurrences are opinionated.

posted by oliviertassinari over 6 years ago

@oliviertassinari I also found a problem with will-change. My problem appears on the MacBook (on the PC all is well). I use the Dialog component. Inside it uses the Fade component with will-change: opacity. If the Dialog contains a lot of content the Paper (used by Dialog inside) should to scroll. A scrolling works well in all tested browsers: the Safary, Chrome, Firefox. But only the Safary and Firefox show a scrollbar at moment of scrolling. I think it's a bug of the Chrome of course, but I found a solution by replaced will-change: opacity on will-change: auto. I also know the Chromebook has the same problem in the Chrome.

posted by MrEfrem over 6 years ago

@MrEfrem If you want to address it, we would more than happy https://github.com/mui-org/material-ui/issues/10831#issuecomment-419715529 :)

posted by oliviertassinari over 6 years ago

@oliviertassinari sorry, I didn't understand what you mean, I just noticed still one problem from using this rule.

posted by MrEfrem over 6 years ago

@oliviertassinari Is this just removing willChange from the JSS inside LinearProgress?

posted by joshwooding over 6 years ago

@joshwooding No, the opposite. The idea is to only use the will change when we 100% know we gonna need it.

posted by oliviertassinari over 6 years ago

@oliviertassinari Ah, okay. I'm not very familiar with willChange. So i'll leave it for someone else

posted by joshwooding over 6 years ago

@issuehuntfest has funded $40.00 to this issue. See it on IssueHunt

posted by IssueHuntBot over 6 years ago

Fund this Issue

$40.00
Funded
Only logged in users can fund an issue

Pull requests

Recent activities

issuehuntfest funded 40.00 for mui-org/material-ui# 10831
over 6 years ago