-
-
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
Fabricjs doesn't release mouse event handlers on dispose #5013
Comments
i have to admit this is a weird setup, but i also think we should clear them better. Also the dispose is not clearing some dimension and if you are on retina screen the canvas size grow indefintely |
I set a very short timeframe for the setInterval here, normally I clear each 5 seconds to adjust the canvas size and some other params, it still has a chance to blowup if the user is holding his mouse when I dispose() I am on a retina screen, what do you mean by not clearing some dimensions? is there a way to recreate a fresh fabric object without having to refresh the page? that is basically what I am trying to achieve. Thanks |
dispose should do it, needs to be fixed for events. |
@asturur oh I see, the width/height bug seems to only happen when you do not specify |
now that i think of it, since the canvas event handlers do get cleared, what i m thinking that may be missing is that we appen an event to document in order to handle mouse move outside the canvas |
if you want to build fabric from here and have a test: i ll do when i can. |
@asturur I tried to build and I got some errors about fabric constructor when I tried to run, probably my fault, the fix seems logical so I will just wait for the official build when it comes (no pressure I have a workaround for meantime) Thanks for the quick response :) |
Version
2.3.0
Test Case
http://jsfiddle.net/Da7SP/1660/
Goal
Refresh the canvas object frequently, refreshing means to dispose() the current fabric canvas and then recreate it immediately.
Steps to reproduce
Expected Behavior
Dispose() should clean everything related to fabric, allowing you to recreate a new fabric if you wish so, and should always clean all event handlers and all data
Actual Behavior
Dispose() won't really clean fabric if a mouse event is already in progress (mouse down), causing a bug that will fail the browser until a full webpage refresh
Final words
It seems like fabric is registering some GLOBAL(document) events on mouse:down and do not release them on dispose causing errors if you happen to call dispose() while the user clicked on something in the canvas
When I run
getEventListeners(document)
[on my webpage not on the fiddle, in the fiddle you would need to get the document of the html VM window not the fiddle window] I get:{click: Array(2)}
Each time I recreate this bug and list the
getEventListeners(document)
I get:{click: Array(2), touchend: Array(1), touchmove: Array(1), mouseup: Array(1), mousemove: Array(1)}
And if I cause it again:
{click: Array(2), touchend: Array(2), touchmove: Array(2), mouseup: Array(2), mousemove: Array(2)}
So it seems like
touchend,touchmove,mouseup,mousemove
do not get cleaned if an event was mid-air while disposing.The text was updated successfully, but these errors were encountered: