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

actions menu: documentClickHandler is not removed #733

Closed
pelikhan opened this issue Aug 4, 2021 · 7 comments
Closed

actions menu: documentClickHandler is not removed #733

pelikhan opened this issue Aug 4, 2021 · 7 comments

Comments

@pelikhan
Copy link

pelikhan commented Aug 4, 2021

This is an issue that arised while using react-vega so it might have to be moved upstream.

There is a memory leak in the registeration of the actions mmenu. The document click handler is registered everytime the spec or data buffer is updated in react-vega; and it won't be garbage collected.

document.addEventListener('click', documentClickHandler);

Thank you for this great project!

@pelikhan pelikhan changed the title documentClickHandler is not actions menu: documentClickHandler is not removed Aug 4, 2021
@domoritz
Copy link
Member

domoritz commented Aug 5, 2021

Is this vega/react-vega#383? Calling finalize should remove the handler:

document.removeEventListener('click', documentClickHandler);
.

@pelikhan
Copy link
Author

pelikhan commented Aug 5, 2021

I tried to trace where documentClickHandler would be removed but could not find suck code. So I think it is not related.

@domoritz
Copy link
Member

domoritz commented Aug 5, 2021

I'm not following. I think the issue is in react vega, not embed. Do you agree?

@pelikhan
Copy link
Author

pelikhan commented Aug 5, 2021 via email

@domoritz
Copy link
Member

domoritz commented Aug 5, 2021

Vega view has a finalize method that should clean that up. If it doesn't, please file an issue with a reproduction in Vega.

I'll close the issue here for now as I don't think embed has a bug.

@domoritz domoritz closed this as completed Aug 5, 2021
@pelikhan
Copy link
Author

pelikhan commented Aug 5, 2021

If i am not mistakened, the callback is created by vega-embed and added to the document click handlers. I don't see how vega finalize would be able to clean up this callback.

It is declared in this scope at

let documentClickHandler: ((this: Document, ev: MouseEvent) => void) | undefined;

and added to document.click at
document.addEventListener('click', documentClickHandler);

@domoritz
Copy link
Member

domoritz commented Aug 5, 2021

Embed has its own finalize (which calls Vega view finalize) that you need to call.

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

No branches or pull requests

2 participants