-
-
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
[Slider] Fix memory leaks #12537
[Slider] Fix memory leaks #12537
Conversation
@@ -142,6 +142,10 @@ function addEventListener(node, event, handler, capture) { | |||
}, | |||
}; | |||
} | |||
// mock return value of addEventListener with noop; used as default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, I would stick to the same API as we use in the rest of the codebase. I'm not aware we use the remove
structure anymore: https://github.com/mui-org/material-ui/blob/50c656b27817c14f5afee8ebef5345a504c7662b/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js#L321
https://github.com/mui-org/material-ui/blob/50c656b27817c14f5afee8ebef5345a504c7662b/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js#L329
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just refactored the existing pattern but I'll change it.
4050123
to
c5209a4
Compare
I'd like to wait for #12535 to be merged to see if the tests account for this change. They were broken before the test so they currently have little significance to the correctness of this change. |
c5209a4
to
c9a687d
Compare
d7a96c7
to
ad9af5b
Compare
Rebased to resolve unrelated CI fails. I'm not quite satisfied with the leak tests since they don't check for the timeout which could potentially throw errors in other tests (it was not trivial to provide a custom theme to the component while also being able to test the state of the slider; see enzymejs/enzyme#1289). However I'm confident that we can skip the setTimeout call completely which would make the component easier to test and reason about. I think that the original author wanted to emulate serial transitions on the thumb (first to left/top then the width) which can be achieved by css transitions alone. Currently the jumped state and transition time don't have the same duration anyway which already grants another look at the behavior. |
@eps1lon Great to have someone with your obvious experience working on this! 👍 |
ad9af5b
to
e92b1c6
Compare
Rebased with master. PR is ready for review. |
@eps1lon Great PR. Thanks! |
Removes 2 potential errors and one that already was showing up sometimes in CI.
Basically #11889 added global event listeners that were not removed when the component was unmounted which could cause leaks or errors if the component is unmounted between mousedown and mouseup.
The timeout related leak was not dangerous but triggers react warnings.
Fixes one error surfaced in #12531