w3c / performance-timeline

Performance Timeline
https://w3c.github.io/performance-timeline/
Other
111 stars 27 forks source link

Add support for accessing cross-frame entries. #202

Open clelland opened 2 years ago

clelland commented 2 years ago

This adds a Document-Policy configuration point for documents, named "share-performance-timeline-with", which acceps a set of origins. If it is non-empty, then ancestor frames whose origins are contained in that set can access the timeline entries of the child frame, either through a PerformanceObserver, or by passing a boolean flag into the various getEntries methods.


Preview | Diff

clelland commented 2 years ago

I think this is still missing a piece -- PerformanceObservers shouldn't always get events from child frames; that needs to be conditional on PerformanceObserverInit.includeFrames.

Additionally, the way this is written may cause the finite buffers to overflow quickly; I should find a way to avoid that

yoavweiss commented 2 years ago

This seems generally reasonable. May be good to share this with the WG, and see what folks think of the general shape

clelland commented 2 years ago

WG is generally supportive (discussed at the 2022-11-10 meeting)

One question was brought up about feature detection, and how developers could know whether cross-frame entries are supported at all, if we just use a boolean parameter on getEntries*.

After some consideration, I think that developers should be able to detect the presence of this feature by looking for the source property on the PerformanceEntry interface; something like

Object.getOwnPropertyNames(PerformanceEntry.prototype).indexOf('source') != -1
noamr commented 1 year ago

Another thing I didn't see here or in the design document is reference to to timeOrigin. Entries from different frames are going to be of different time origins and thus out of sync. I guess we could have the time origin as a property in each cross-frame entry? Would that be ergonomic?