[go: up one dir, main page]

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

Cannot find a way to unmount/remove a game from a page. #42

Open
vlinder opened this issue Apr 17, 2019 · 5 comments
Open

Cannot find a way to unmount/remove a game from a page. #42

vlinder opened this issue Apr 17, 2019 · 5 comments

Comments

@vlinder
Copy link
Contributor
vlinder commented Apr 17, 2019

Have been looking into the source and cannot find a way to remove a game from a page?

Is this not a use case that was designed for or maybe just overlooked?

@aprescott
Copy link
Owner

I hadn't considered this to be a thing that tenuki should solve for. I think my expectation is that removing a board from the page is very likely to require you to handle the empty content in some way, and everyone's needs would be slightly different.

Are you able to keep a handle on the DOM element you gave to the game constructor and remove it from the DOM with, say, remove()?

@vlinder
Copy link
Contributor Author
vlinder commented Apr 20, 2019

I had some problems with a memory leak. But maybe if I remove the passed element all event listeners and such will be gone as well? I tried just clearing the innerHTML of that element but that did not seem to fix it.

@vlinder
Copy link
Contributor Author
vlinder commented Apr 20, 2019

Still have the same problem. It retains a lot of detached svg elements and event listeners for some reason. Running garbage collection manually does not seem to collect them.

image

After creating a few of these games the tab becomes really sluggish.

@vlinder
Copy link
Contributor Author
vlinder commented Apr 22, 2019

Found the problem. Lines like this have access to the closure of the function that defines them, so the closure for the event handler will keep all references alive from that scope. Since the event is on window the handler will never be collected. Causing it to remain alive and keep everything else in memory.

window.addEventListener("optimizedResize", () => {

There is also closures created for requestAnimationFrame. And probably others I haven't found yet.

@milescrawford
Copy link

I am interested in this too - trying to set up a way to practice various joseki repeatedly, and I'm looking for an efficient way to "reset" or remove/recreate the board. Is there any change or workarounds that have arisen in the last few years?

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

3 participants