-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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(Canvas): sync cleanup of dom elements in dispose #8903
Conversation
Build Stats
|
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.
- expose
cleanupDOM
on canvas that runs from dispoe (sync) - moved
dispose
to node env and use only inindex.node
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.
Shouldn't we dispose of all cache canvases in Object#dispose??
src/Pattern/index.ts
Outdated
@@ -1,2 +1,2 @@ | |||
export { Pattern } from './Pattern'; | |||
export type * from './types'; |
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.
ts warning
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 think this ok
It is better than #8901 for the case of running an async toCanvasElement
during disposing but I don't like the jsdom dispose thing
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.
added disposing to object...
I have to say I don't like it and prefer to have that specific dispose logic in the node entry only like I did with image before I reverted.
But it means we need to apply a mixin to fabricObject to patch destroy
|
Well, yes. Thinking of it I dislike this. |
I would argue that we should combine the 2. |
just did that in #8901 |
i don't like the idea of try catching in a render because regardless of typescript requiring us a context, then we know there are situation in which will fail anyway because somethin could fire a render after dispose. On top of that again, the issue here is not to be sync or async, is the interaction with react and we need a foolproof react wrapper at some point, and cleaning up the dom elements is just a part of it. Probably ( didn't test ) you don't even need to dispoe the canvas on hot reload, you can even just call cleanupDOM and let the instance be garbage collected naturally. |
Is also important that before reverting and changing idea on something we think twice or three times. |
Please give an explanation why you dislike this approach and then close the pr. |
I saw you commented on garbage collection. |
What do you think? What I have against it: |
A one issue that we got in the past is that node was accumulating canvases buffer till would give an exception. |
I would expect that to be fixed by node-canvas |
Motivation
closes #8901
closes #8899
Description
Changes
cleanupDOM
on canvas that runs from dispoe (sync)dispose
to node env and use only inindex.node
Gist
In Action