-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Fix use-directives called multiple times #4781
Conversation
@christianheine The fix doesn't seem to be working for me. Perhaps I'm testing it incorrectly or maybe misunderstanding the scope of the fix. Here is the relevant section of my application code (SVG): <g transform="translate({$viewportX}, {$viewportY})">
{#each $renderingOrder as id (id)}
<GameObject {id} />
{/each}
</g>
Observation
|
Yes it is a temporary fix that calls |
Understood. For the record, here is what breaks in my application. I'm implementing drag-n-drop via a use directive:
I also "raise" the element in [1] by moving it to the end of the rendering order. This is necessary in SVG because of the lack of a "z-index" equivalent. However, this causes the directive to rerun, therefore losing the mousemove and mouseup handlers. The effect is that you can click on an element, but it does not drag on mousemove. Perhaps this is not a good pattern to begin with irrespective of the bug in use directives? |
No you're good @nicolodavis, the problem comes from svelte |
i think you are right @pushkine, that looks like a good fix for now. |
@christianheine thank you for documenting this bug and submitting a fix. I was a little unsure about passing |
Fixes #4693.
Additional remarks:
As far as I can tell, the fix seems to be working fine. I added a new test which covers the problem (thanks @pushkine !) and also thoroughly tested this version in a rather large scale app.
But, as already discussed in the issue, I think @pushkine has a valid point that this should be considered more of a a short-term remedy to address the (potentially huge) memory leak caused by mounting directives over and over. A more thorough approach would be in order in the long run.