w3c / performance-timeline

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

Determining if the buffer was full when using the buffered flag #169

Closed nicjansma closed 4 years ago

nicjansma commented 4 years ago

When using PerformanceObserver with the buffered: true flag, it would be useful to know if that buffer was "full" when the buffered data is delivered.

Example:

const resourceObserver = new PerformanceObserver(list => {
  if (list.bufferFull) { // <--- can we get something like this?
    // take some action to note the buffer may not be the complete picture
  }
  list.getEntries().doSomething();
});
resourceObserver.observe({type: "resource", buffered: true});

This kind of flag would help with knowing if the data being fetched is the complete picture, or just a partial view as a result of fetching the PO entries too late. For example, when third-party analytics load later on the page (to avoid affecting the page load time), if we know the buffer we're querying was already full, we can mark it as "incomplete" in our analytics and/or help the site owner increase the buffer size if desired (e.g. for ResourceTiming specifically).

While it might be possible to infer that the buffer you're retrieving is full by noticing that it is at a well known length (e.g. 150 or 250 entries in the case of ResourceTiming), I think in practice this would be error-prone:

npm1 commented 4 years ago

The feature request makes sense to me! Things I'm not so clear about:

nicjansma commented 4 years ago

@yoavweiss also brought up that the signal that we're looking for isn't necessarily the size of the buffer or whether it's full, but whether there were any dropped entries for the buffer.

So the proposal would be to have a flag (or flags) (or API) that exposed whether that buffer had dropped entries.