- From: François REMY <notifications@github.com>
- Date: Sun, 02 Dec 2018 22:48:18 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/713/443606097@github.com>
Hey, for what this is worth, I do believe the current design in the spec is incorrect. Indeed, if the context stores a list of all the active MutationObserver, this list can either be holding strong references to the MOs or weak references to the MOs. Both approaches are not satisfactory. 1. Strong references If the context holds strong references to the MOs, since the list of MOs is never emptied anywhere, MOs will leak forever and never get GCed. 2. Weak references If the list holds weak references, it is possible for a MOs that had pending notifications to be GCed before those notifications get processed, which should not be possible. --------------------------- According to me, the correct design here is not to have a list of all MOs in the context, but only have a list of MOs which currently do have at least one pending notification. When a notification is pushed into a MO, the MO is appended to the "active MO" list with a strong reference. When notifications to MOs are about to be sent, the list of active MOs is copied then emptied, and notifications are sent to the MOs that are in the list at the time. I do believe this is what Blink and Webkit implement, and I am pretty sure this is how this is implemented in Edge as well, from the last time I looked at the code. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/713#issuecomment-443606097
Received on Monday, 3 December 2018 06:48:40 UTC