Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport performing generic operations on DOM objects during document teardown #24483
Comments
|
Could you elaborate on how you envision the proposed Personally I liked the pattern used in #23637 (and also starting to be applied in #24123) where one would:
The above might appear like overkill for most DOM objects(and there might be a more generic way to do this), and it might actually make sense for DOM objects that involve some communication with non-script components, including clean-ups. For example in the case of So one can imagine making Also note that the HTML spec has a hook to define specific clean-up steps triggered as part of document unloading, which for example the File API is using. So it might make sense to also define such unloading-document-cleanup-steps for WebXr, if is hasn't been done already. |
For problems like #23986 and #24052, we have code that currently runs in DOM objects' Drop method because that's the easiest way to deal with "something needs to be unregistered when the DOM object no longer exists". Destructors interact poorly with the GC and can operate in invalid or unexpected states, so we should add a way for DOM objects to opt-in to some kind of cleanup action when a global is being torn down (
servo/components/script/dom/window.rs
Line 1330 in 58c61d3