-
Notifications
You must be signed in to change notification settings - Fork 26
Description
I'd like to discuss a method for registering a PerformanceObserver that would notify me of the observable entries from all (same-origin) frames on the page, from the root frame plus all (same-origin) descendants (children, grand-children, etc).
The motivation for this is that we'd like to be able to monitor the complete picture of events happening on the page (as an example, ResourceTiming entries), in every frame, without having to register a PerformanceObserver in all of those frames.
With today's PerformanceObserver, if we want to monitor all frames, at startup, we'll register PO for the root frame, then traverse the frame.frames tree to access all same-origin frames, registering POs there as well. Once we've done that, we'll have to translate events from any descendant frame's time-origin to the root frame's time origin.
After doing the above, what about new IFRAMEs that get added to the page dynamically? We'd either have to register a MutationObserver to listen in all of these frames just to be notified of any new frames (ugh! talk about observer effect!), or crawl the frame tree later (at beacon time) to see which ones didn't have a PO registered, and hope their buffers hadn't been filled up.
Instead, I'd love to get a bubbles: true flag (there's probably a better name) available during PO registration:
observer.observe({
entryTypes: ["resource", "mark", "measure"],
buffered: true,
bubbles: true
});
If set, this would:
- Notify me of any matching entries in any of my (same origin) descendant frames
- Any new frames that are created anywhere in my tree would automatically be included
- Translate the time-origin from any descendant entries to the registered frame's time-origin
- Give me minimal frame attribution so I have a vague idea where it came from
(note, LongTasks already kind of does this, as it notifies you of entries happening in same- and cross-origin frames).