Re: [whatwg/dom] Add AbortSignal.any() (PR #1152)

Yeah, I wasn't sure if this section actually belonged or not, but there is precedent in the DOM spec [here](https://dom.spec.whatwg.org/#garbage-collection). I included this because GC/memory management of composite signals was a concern in the [related issue](https://github.com/whatwg/dom/issues/920), so I wanted to include it to hopefully help guide other implementors.

FYI: there's one design decision related to the linking algorithm that helps support memory management and is observable: AbortSignal.any() always links the resulting signal to a non-composite signal (timeout or associated with a controller). This basically flattens the signal graph to a depth of 1, meaning intermediate composite signals don't need to be kept alive just to propagate abort. This affects the order events fire, which is covered in tests.

> Well, although we don't always do a good job at this, we do need to describe relationships between objects in a way that allows GC to eventually succeed. And I don't think we should accept "agent lifetime" as a way out, although sometimes that is acceptable.
> 
> I hadn't looked at the GC section here yet, I was hoping @smaug---- could take a look at that. But now that I have:
> 
> * Strong references are implied so don't need to be stated.
> * That something is a weak reference should be mentioned as part of the definition, not in a separate section.

FWIW I was using https://dom.spec.whatwg.org/#garbage-collection as an example, which should probably also get cleaned up then?:
 1. "Nodes have a strong reference to registered observers in their registered observer list." → strong is implied
 2. "Registered observers in a node’s registered observer list have a weak reference to the node." → this should probably move to the section where registered observers are defined? Or maybe this is about a mutation observer's node list? I can't tell exactly what that reference is.

> * The GC section should mainly state when something can be GC'd or ideally what prevents GC when GC would otherwise be possible. https://xhr.spec.whatwg.org/#garbage-collection is an example of that, although I think there's been a suggestion that user agents will never collect when the connection is still open either, so maybe that should be a must not instead.
>

Thanks, I'll have a look at that and clean this up.

> (I hope that at some point JS/IDL formalize some of these aspects better so we can ground terminology like "weak reference" in terms of a larger web platform memory model.)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1152#issuecomment-1424788407

You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/1152/c1424788407@github.com>

Received on Thursday, 9 February 2023 20:38:22 UTC