-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
Memory leak with dynamic styles #1360
Comments
the leak selector is
and i have tried |
will it happen if you just put this?:
|
Can you reproduce it without using react and material-ui? If the assumption is that it's exactly this rule, it means you only need jss core and jss-plugin-nested for reproduction. If we don't have a bare minimum for reproduction we are unlikely to fix it. |
yeah,
this selector is the same issue. |
i reproduced it in this sandbox: https://codesandbox.io/s/strange-hill-z3gwr?file=/index.html |
@qhxin good catch, I can see the bug is somewhere between these two plugins jss-plugin-rule-value-function and jss-plugin-nested, do you or anyone else want to fix it? |
@kof It seems I want to help for this. Now I need to know if there is anyway to remove old useless rule when add, or I have to start with it. |
@kof I try to read the code, I can't quite understand about this code: let key = name
if (name in this.raw) {
key = `${name}-d${this.counter++}`
} when addRule to RuleList, even if the same rule name exist, it just create a new name, this make same rule add to rule list every time. Why we need to do like this? |
@Jokcy right above that line there is the comment:
Is this not explaining it? |
Yeah, I already read that, my quesstion actually is about it, why we need to keep rules with same name? I just start to read jss code yesterday, so I did not catch a lot of detail now. |
Mainly because as a user you may call sheet.addRule() from where you are not aware if there is another rule with the same name already there, so the idea was to allow doing so while resolving name conflicts automatically. I wonder if there is no way in our case here to identify the same rule (without stringification) |
Also feel free to locally disable this line and run the tests to see what other use cases will be failing. |
@kof I'm wondering if we can just add another API to fix this. In this API we won't do: if (name in this.raw) {
key = `${name}-d${this.counter++}`
} This API just for plugins and people who know this issue. I tested in the codesandbox demo, it did work, but I got some test cases need to fix. I need some advice to know if I went into bad direction. |
cssinjs/jss would be eliminated by material-ui... |
I found that we should take care of following to solve the memory leak.
|
Expected behavior:
My APP must render very frequently by our realtime data.
Describe the bug:
My APP has memory leak on Firefox, after using material-ui.
This is the same issue in material-ui mui/material-ui#21528
Codesandbox link:
https://codesandbox.io/s/dazzling-visvesvaraya-eczqe?file=/src/Tab.js
Versions (please complete the following information):
Feel free to add any additional versions which you may think are relevant to the bug.
The text was updated successfully, but these errors were encountered: