-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When are new entries delivered to observer? #13
Comments
Agreed that they should be delivered only when complete. Maybe the real bug here is that there are a few "events" that have sibling "early" events. E.g. there's resource load events which are post-facto (and thus can take a while). But maybe there are down the road fetch events too that show the earlier timings... This all gets to us moving to a stronger PerformanceObserver model: when we say that new events only go into the observer and not to the global timeline, then it becomes easier for us to add events for use cases instead of fearing saturating the timeline like we used to. |
I would like to see if there's a way we could allow consumers of ResourceTiming to get notified of new entries prior to their completion (eg before Ideally, I would like to be notified of new RT entries as soon as One use case is to allow pages to monitor for new outgoing network requests, which would also give you the ability to know how many networking requests are in-flight. You could theoretically build a "busy" indicator with this. Specifically, what we want, is to be able to better monitor when all of the resources triggered by a SPA soft navigation have completed. The body 'onload' event is no longer relevant for SPA apps. Today we're doing this by monitoring for changes to the DOM via MutationObserver and hooking into onload/onerror events, which is not efficient. We also cannot monitor all types of resources in this way (eg fonts). Alternatively, what if there was a new |
I took a quick look at the Fetch registry proposal, and while I think it could potentially be used to determine if there are any outstanding network fetches (if it exposes the appropriate data via JS), there's no talk of having a notification event about new entries. Ideally I'd like there to be an event so we don't have to poll. That's one of the reasons I think the PerformanceObserver interface would be so ideal for this. I see a couple options:
No strong opinion on which is best, but number 3 seems the most straightforward. |
adding @annevk since it interacts with fetch |
@nicjansma we could eventually have events I suppose. We should if we expose it as an API. The shape of that API is still unclear though. Perhaps some kind of observer similar to DOM observers is better. |
@nicjansma if we were to solve this within perf-timeline, then (3) seems most reasonable to me. Intuitively, I think of this as "mark" vs "measure": a task may have many marks, and at the end it emits a measure which captures all/some of the emitted marks as a "summary". For example a resource fetch may emit marks for each milestone (dns, tcp, etc), and then a summary record at the end. That said, for this particular case of knowing when a new request has started, it does seem that proposed registry would be sufficient. |
@igrigorik I like that analogy. (3) sounds good to me. |
@nicjansma to clarify, I'm saying (3) seems like the most reasonable if we want to solve this as a general problem within perf timeline. But, for the particular use case of notifications of new fetches, it seems that registry solution is sufficient. So, the open question now is whether we have concrete and high-value use cases for pursuing (3). |
The three main use cases I've come up with give third-party scripts insight into an app's network activity without invasive instrumentation:
|
@nicjansma thanks. I think all of those are addressable via the registry, correct? FWIW, see: |
@igrigorik Looks good |
What about Frame Timing? |
Some entries have attributes that may take a long time to "finalize". For example, it may take 10s+ to get the
loadEventEnd
timestamp for NavigationTiming. When does an entry with such attributes become visible to the observer? Once all the attributes values are known, or can the entry be delivered sooner? We should clarify this in the spec.Thinking out loud.. it seems like they would have to be delivered once finalized. If they're not, then you run into interesting issues: observer gets notified and calls getEntries(), which returns a copy of the event with partial attributes. However, from that point forward the retrieved entry wouldn't be updated with new attribute values, and observer wouldn't fire notifications for same entry with new attributes either, so there is no way to observe updated values.
The text was updated successfully, but these errors were encountered: