Properly remove window mouse event listeners#2632
Properly remove window mouse event listeners#2632madsmtm merged 4 commits intorust-windowing:masterfrom DouglasDwyer:ms-web-mouse-event
Conversation
|
It looks like you're right about that, but I'm stumped as to how you managed to observe it in the first place. Even for seemingly obvious stuff like this, I prefer to reproduce the error and observe that the fix works as intended. |
|
@maroider Absolutely! This can be reproduced by creating a Winit window on the web platform, and then dropping it, while allowing the event loop to continue. When you wave your cursor over the browser window after this happens, errors about a destroyed closure should appear in the console. |
|
I had a go at following your instructions, but I couldn't get the error to show up in the console. It's probably fine to merge it as-is, even if I couldn't reproduce the issue, as the MDN docs clearly show we're using |
|
Thank you @DouglasDwyer! |
CHANGELOG.mdif knowledge of this change could be valuable to usersThe web backend for
winitregisters theonmousedown,onmouseup, andonmousemoveevents on the global Javascript window object. When thewinitwindow is destroyed, however, these events are not properly removed. This is because the events are registered with thecapture: true, butcapture: trueis not passed to the appropriateremoveEventListenercall. This PR updates the web backend to pass the event creation options to the event removal function. This prevents errors in which the Javascript runtime tries to invoke the event listener closures after they are destroyed.