You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See e.g. #5456 (comment) and other reports in the past. If one creates event handlers then the module cannot be GC'd even if nothing but the event handlers refers to it. The handlers must be unregistered manually.
If all event handlers used a WeakRef to everything else, then the module can be gc'd, and then the event handler can see it can just exit (and unregister itself).
As WeakRefs are not supported everywhere yet, we'd need to check for their presence.
I'm not sure if this would need to be an option or not. Doing it automatically would help some things, but maybe some codebases do want to stay alive due to event handlers.
If one does not want to manually track and release all event handlers, one can call the JS function removeAllEventListeners to do that in one go. That function should probably be hoisted to a extern void emscripten_remove_all_event_callbacks(void); in system/include/emscripten/html5.h to make it publicly accessible from C code, if someone wants to take a stab at that.
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.
Activity
juj commentedon Nov 25, 2019
If one does not want to manually track and release all event handlers, one can call the JS function removeAllEventListeners to do that in one go. That function should probably be hoisted to a
extern void emscripten_remove_all_event_callbacks(void);insystem/include/emscripten/html5.hto make it publicly accessible from C code, if someone wants to take a stab at that.stale commentedon Nov 24, 2020
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.
jeffRTC commentedon May 7, 2021
@juj That doesn't works when you have a Dispatcher function where you create a new Module for each time for each event.