[resize-observer] Suggest using weak references
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
https://drafts.csswg.org/resize-observer/
Mutation observers suggest that they have a weak reference to observed elements, so if the element is otherwise garbage collected, then the observer is also collected. This seems to work in practice.
However, with similar code, ResizeObserver leaks memory. The same happens with IntersectionObserver.
https://bugs.chromium.org/p/chromium/issues/detail?id=1220041 (includes demos) - the same issue effects Firefox and Safari.
The ResizeObserver spec should suggest that observed elements are weakly referenced, similar to MutationObserver.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the linked Resize Observer draft and compare its handling of observed elements with the MutationObserver garbage-collection guidance. Review the linked IntersectionObserver issue and Chromium bug demos for the reported leak. Done means the ResizeObserver specification clearly recommends weakly referencing observed elements, if that behavior is appropriate.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation, web-dev
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100