-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[styles] My app have memory leak on browser after using material-ui. #21528
Comments
I can't recreate this using the codesandbox on Firefox 78.0b9 (64-bit) or Chrome 83.0.4103.116 (Official Build) (64-bit) What environment did you encounter this in and can you definitely reproduce with the codesandbox? |
For memory leak related issues please make sure to include whether
|
@eps1lon tks for reply me, i hav'nt use StrictMode, and leak is caused in dev & prod Firefox/Safari env. |
@qhxin Can you post your version of Firefox and confirm you could reproduce this using the codesandbox? |
I've forked it and deployed it: https://csb-qvhqs.netlify.app/. Please make sure that we know if this reproduces in prod or dev. |
Tried using @eps1lon's deployment to reproduce it and still can't after 4 hours. It's amazing to have a visual representation of how much production mode increases performance. |
@joshwooding @eps1lon after long time debug, i found it's caused by my Tab style. The demo is: https://codesandbox.io/s/dazzling-visvesvaraya-eczqe?file=/src/Tab.js This code is the reason that makes Firefox rule tree leak.
|
@oliviertassinari pls open this issue again. |
I can reproduce the memory leak but I believe this is a jss issue. Edit: This might be a duplicate of #21143 |
Is about dynamic styles. https://codesandbox.io/s/dazzling-visvesvaraya-eczqe?file=/src/Tab.js only uses static styles. Updated the initial post to use https://codesandbox.io/s/dazzling-visvesvaraya-eczqe?file=/src/Tab.js. The original sandbox could not reproduce the issue. |
So how can i fix this? |
okk, i think it's about jss plugin issue , reproduced in cssinjs/jss#1360 |
An update, this issue is being resolved in v5 thanks to #22342 and the new |
is there any code example to fix this issue? upgrade @material/ui to v5 or other way? |
@qhxin You can use the new import { experimentalStyled as styled } from '@material-ui/core/styles'; It wraps emotion. |
so, it will be a styled-component ---- not a react hook? |
@qhxin Yes, so far the plan is to remove the makeStyles and withStyles API progressively (v6). |
ohhh, it will cause many extra working |
@oliviertassinari is makeStyles/withStyles going to be replaced with experimentalStyled? |
@mentierd It's the long-term direction, yes, also replaced with the |
An update, we have now made enough progress with the new
This was made possible by the awesome work of @mnajdova. |
import { experimentalStyled as styled } from '@material-ui/core/styles'; using this causes this error: Attempted import error: 'experimentalStyled' is not exported from '@material-ui/styled-engine' (imported as 'styled'). My current versions are :
Also, am using typescript and have added this in tsconfig.json : "paths": { Any help is appreciated. |
@jasonburnell98 you can reference the examples we have in the repo for instructions on how to setup a starter project. |
Hi @mnajdova , I will take a look however I am trying to implement this in an existing project |
I am able to get this running fine in a startup project but whenever I try to migrate from makeStyles to styled in my existing project I run in to all sorts of dependency issues. |
@jasonburnell98 What's the error message. Is it withStyles and makeStyles import related? @mnajdova A thought: What if:
Could it make the migration easier with a relatively low cost for us? |
@oliviertassinari Yes it is with makeStyles, I fixed most of the dependency problems and after updating my project and running some of the migration scripts, for the files in node_modules, found in the docs (v4 to v5), I am now getting this error: Failed to compile. ./node_modules/notistack/dist/notistack.esm.js I'm going to look through the docs to see if there is some help for this specific error but I appreciate your staying in touch with me on this. |
@oliviertassinari just to clarify, are you suggesting this only during the alpha/beta stage of v5? If so, yes I think we can add them. When you say deep import, do you mean this?
Also, should we then just re-export them so that they won't have the default theme?
@jasonburnell98 see iamhosseindhv/notistack#387, hopefully I will manage to test out everything today and get it closer to the stage where it can be merged. |
@mnajdova My bad, I forgot that we don't import makeStyles and withStyles with a direct path. My proposal won't work 😁. |
@mnajdova Or I suppose your plan was to update the import for notistack. |
Thanks for getting back to me! |
Hello, I just had a very similar issue with , which caused a memory leak in our application where elements frequently changed due to live data streamed by socket-io. The changing elements were within the ThemeProvider. It took me a very long time to figure out that the ThemeProvider was causing these issues. It would be great if this issue could be fixed in the future because it is super unexpected and frustrating. I can also create a separate issue if that makes sense. Used Version: |
@MarvinThiele We have closed this issue because fixed in v5. Please upgrade and test the leak again. |
Thank you for the quick response. I tried your suggestion and the issue disappeared after updating. I'm not sure, but such an issue might be worth a hotfix or patch on the v4.x release besides being fixed in the new v5 beta branch? This bug is potentially site-breaking and it is not clear that a ThemeProvider could cause such an issue. Anyways, thanks for your help and I'm really grateful for your efforts with MaterialUI in general! :) |
By default, we don't backport, we leverage these types of improvements as counter parts to breaking changes. We occasionally backport important changes, for instance, when we need them for internal purposes or when a third party introduces a regressions e.g. a change in Chrome. |
I'm experiencing this issue after migrating to @mui v5 |
@AdiGutner can you share some more information? Are you still using |
Current Behavior 😯
My APP has memory leak on Firefox, after using material-ui.
Expected Behavior 🤔
My APP must render very frequently by our realtime data.
Steps to Reproduce 🕹
Steps:
makeStyles
to createuseStyles
hook;useStyles
hook in components.Context 🔦
https://codesandbox.io/s/inspiring-waterfall-e197h?file=/src/App.jscodesandbox.io/s/dazzling-visvesvaraya-eczqe?file=/src/Tab.js
Your Environment 🌎
Edit @eps1lon: Added codesandbox.io/s/dazzling-visvesvaraya-eczqe?file=/src/Tab.js as repro.
The text was updated successfully, but these errors were encountered: