Skip to content
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

fix memory leak again #1574

Closed
wants to merge 15 commits into from
Closed

Conversation

seiyab
Copy link
Member

@seiyab seiyab commented Oct 29, 2021

Corresponding Issue(s):

#1360 #1565

What Would You Like to Add/Fix?

Memory leak in nested function rule

Todo

  • Add test(s) that verify the modified behavior
  • Add documentation if it changes public API

Expectations on Changes

Changelog

@seiyab seiyab requested a review from kof as a code owner October 29, 2021 13:40
let style
let sheet

// We skip this test as keyframes are not supported by browser.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should drop support the support of IE9, probably even IE10 too, so this won't be needed, but also not in the same pr, just letting you know

@kof
Copy link
Member

kof commented Oct 29, 2021

Good work @seiyab, which change fixes the concerns we had with the previous PR? I mean besides of splicing the index

@seiyab
Copy link
Member Author

seiyab commented Oct 30, 2021

@kof
Current work just addresses splicing the index.
I'll work with replaceRule is not a function in other commits in this PR. mui/mui-x#2993 (comment)
And I'm going to add more tests.

@seiyab seiyab marked this pull request as draft November 4, 2021 10:32
@seiyab
Copy link
Member Author

seiyab commented Nov 7, 2021

Current progress

  • fixed
    • splicing cssRules index
    • replaceRule is not a function
  • working
    • react-jss might still cause memory leak. investigating.

@kof
Copy link
Member

kof commented Nov 7, 2021

just in case - react-css isn't documented, its an experimental interface that hopefully nobody is using in production

@seiyab
Copy link
Member Author

seiyab commented Nov 8, 2021

Oh I mistyped. I edited my comment. react-cssreact-jss

@seiyab seiyab closed this Nov 8, 2021
@seiyab seiyab reopened this Nov 8, 2021
@seiyab
Copy link
Member Author

seiyab commented Nov 8, 2021

The memory leak I encountered was generated by nested conditional rule, that is out of scope for this fix.
This PR might be ready for review. I will check changes I wrote before pushing "Ready for review" button.

.prettierrc Outdated
@@ -3,5 +3,6 @@
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"printWidth": 100
"printWidth": 100,
"arrowParens": "always"
Copy link
Member Author

@seiyab seiyab Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you added parentheses, that is removed by Prettier that runs on pre-commit.
So I changed this configuration to prevent removing parentheses from Prettier.
c60f395

I found lint you committed is more likely written by Prettier v2 rather than v1 installed by devDependency.
When I accidentally run prettier v2 installed globally in my machine and the result was similar to c60f395 .
arrowParens is "always" by default in Prettier v2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets upgrade prettier

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upgraded 👍

@seiyab seiyab marked this pull request as ready for review November 8, 2021 13:35
@seiyab seiyab requested a review from kof November 8, 2021 13:35
@seiyab seiyab changed the title WIP: fix memory leak again fix memory leak again Nov 8, 2021
@@ -36,7 +36,8 @@
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"devDependencies": {
"jss-plugin-nested": "10.8.2"
"jss-plugin-nested": "10.8.2",
"jss-v10_8_0": "npm:[email protected]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks strange

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does strange mean?

  • Doesn't work well?
  • Not good idea?

Removing tests with older jss is OK with me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never seen npm: prefix in dependencies and naming with underscore jss-v10_8_0 like this,
but yeah, lets figure out if we really need to have this compatibility logic and tests

oldJss = oldCreate(settings).use(global())
})

it('should replace rule on replaceRule even if jss core doesn\'t implement replaceRule', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this test? react-jss comes bundled with jss core, so its there, if somebody is using an incompatible version - its on them

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should communicate incompatibility in the changelog, make sure what we expect to work - works, maintaining compatibility logic and compatibility tests feels like a lot of future work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could throw an error if replaceRule doesn't exist and say versions are incompatible, to communicate to the user the problem clearly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.
I removed tests that use incompatible version.

@@ -36,7 +36,8 @@
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"devDependencies": {
"jss-plugin-nested": "10.8.2"
"jss-plugin-nested": "10.8.2",
"jss-v10_8_0": "npm:[email protected]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never seen npm: prefix in dependencies and naming with underscore jss-v10_8_0 like this,
but yeah, lets figure out if we really need to have this compatibility logic and tests

@kof
Copy link
Member

kof commented Nov 23, 2021

Just realized I never sent the last review, it was in the pending state

@seiyab seiyab requested a review from kof November 24, 2021 11:37
@cssinjs cssinjs deleted a comment from oleg008 Dec 8, 2021
@kof
Copy link
Member

kof commented Dec 8, 2021

merged

@kof kof closed this Dec 8, 2021
@kof
Copy link
Member

kof commented Dec 8, 2021

released in v10.9.0

@seiyab seiyab deleted the 1360-fix-memory-leak-again branch December 8, 2021 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants