Closed Bug 1399603 Opened 2 years ago Closed 2 years ago

[intersection-observer] Stop observing a target when intersection root is deleted

Categories

(Core :: Layout, enhancement, P3)

enhancement

Tracking

()

RESOLVED WONTFIX
mozilla58
Tracking Status
firefox57 --- wontfix
firefox58 --- wontfix
firefox59 --- wontfix

People

(Reporter: tschneider, Assigned: tschneider)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Chapter 3.3 of the IntersectionObserver API spec says that an IntersectionObserver should stop observing (and eventually being deleted) a target when the intersection root is deleted. Atm, we hold a strong reference to a custom root element and keeping it alive as long as the IntersectionObserver is. This needs to be changed to the same way we unlink targets from observers when they are deleted.
In worst case we keep root elements (which tend to contain a larger node tree) alive unnecessarily.
Assignee: nobody → tschneider
Blocks: 1381574
Priority: -- → P3
Depends on: 1316277
Comment on attachment 8912009 [details] [diff] [review]
Stop observing a target when intersection root is deleted

Blake, this patch is building up on https://bugzilla.mozilla.org/show_bug.cgi?id=1316277 which you already reviewed. So I figured it a good idea having you reviewing this as well. I discussed this change with dholbert on IRC and we agreed on using the same hashtable for keeping links between elements and  intersection observers, whether they are observing the element or using it as the root element for intersections. We already have everything in place to unlink those pointers properly so it made sense to share this functionality rather then copy and pasting most of the code to introduce yet another list of intersection observer pointers.
Attachment #8912009 - Flags: review?(mrbkap)
Attachment #8912009 - Flags: review?(mrbkap) → review+
Pushed by tschneider@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/f70abea8b810
[intersection-observer] Stop observing a target when intersection root is deleted. r=mrbkap
https://hg.mozilla.org/mozilla-central/rev/f70abea8b810
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
This by all means is wrong. IntersectionObserver has attribute root, and if that magically becomes null after GC, we have exposed GC behavior to the web.
I filed https://github.com/w3c/IntersectionObserver/issues/275
Depends on: 1422092
This was backed out from all branches in bug 1422092.
Resolution: FIXED → WONTFIX
You need to log in before you can comment on or make changes to this bug.