-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Disposing Fabric object within 400 milliseconds after mouse up causes exception #4117
Comments
thabks for the info, may be related to a bug i need to check. |
thanks fixed! |
I am having this exact same issue, I can reproduce it with this same fiddle: http://jsfiddle.net/Da7SP/578/ This fiddle seems to be using 2.6, the most recent version of Fabric.js I get the same error message in my application
Here is my use case. I'm building an Electron app where I am persisting the state of the Fabric canvas to disk, and so far my strategy is to destroy and rebuild the canvas each time the user makes a drawing. Since I am persisting the data, I'd rather re-load it each time an object is added instead of something merging the added object with the canvas already in memory. Starting from page load, here is my code. When my page loads, I run this function.
That function uses these functions: Dispose the canvas if it exists for some reason:
Add event listeners:
Here are the functions triggered by the event listeners:
The error I am flagging in in this issue goes away if I remove this line from the
or, more specifically, if I stop calling this on
So it seems clear that the problem is that even ###after ### the canvas has been disposed with Is there an alternative to |
ok i see the point now. I assume you could avoid disposing the canvas and just clear it or reload the items on top of it, i m not sure how the app works and i do not know if this is the best pattern. |
@asturur thanks. It looks like I should, as you say, not attempt to |
still disposing would be legit. Is also ok to assume after an event there
is dev code that has been run and something should be checked again.
i want to see if it can be done fullproof
…On Mon, 21 Jan 2019, 16:07 kingpalethe ***@***.*** wrote:
@asturur <https://github.com/asturur> thanks. It looks like I should, as
you say, not attempt to .dispose() the Fabric canvas after each drawing,
but instead should be using .clear()
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4117 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABI4QI2ewE7bJfQ7cUfOeLrBPALfGgcUks5vFdevgaJpZM4Ofn5p>
.
|
@asturur this is still happening. One way is to check if contextTop exist, but still that's not always going to be accurate. Should we add something like state/status: 'painted', 'disposing' or something similar? |
does it happen on the last version? |
i think we need to go point by point and make the code safer. |
Version
1.7.16
Test Case
http://jsfiddle.net/Da7SP/578/
Steps to reproduce
Disposing Fabric object on mouse:up event or within 400 milliseconds afterward will cause an exception in timeout set by _onMouseUp handler, that will try to add event listener to destroyed element.
The text was updated successfully, but these errors were encountered: