Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Do not clear the Resource Timing buffer

javascript
bug

#1

The Resource Timing API exposes resource-level performance metrics to the window.performance object. New Relic Browser consumes this data.

The specification sets a minimum recommended buffer size https://www.w3.org/TR/resource-timing-2/#h-extensions-performance-interface of 150. To avoid potential memory issues most browsers set the maximum buffer size to this value (150).

Many pages exceed 150 requests, especially on HTTP/2. This means that the buffer will reach its maximum value often, and stop recording resource timing data after the 150th resource.

The Browser script injected in to pages attempts to overcome this limitation by attaching an event listener to the resourcetimingbufferfull event, which processes the current buffer and then clears it in order to continue collection. While this is a good solution for New Relic (continued resource capture past the 150 limit), it means that any other tools that process Resource Timing data lose access to the prior 150 Resource Timing entries.

Other tools which may require access to this data include, but are not limited to, Real User Monitoring tools, competitive APMs, User Experience analysis tools and thousands of open source projects - https://github.com/search?q=performance.getEntriesByType%28%22resource%22%29&type=Code

The relevant JavaScript code from New Relic Browser is copied below:

        "addEventListener" in window.performance && (window.performance.clearResourceTimings ? window.performance.addEventListener("resourcetimingbufferfull", function(t) {
            i("bstResource", [window.performance.getEntriesByType("resource")]), window.performance.clearResourceTimings()
        }, !1) : window.performance.addEventListener("webkitresourcetimingbufferfull", function(t) {
            i("bstResource", [window.performance.getEntriesByType("resource")]), window.performance.webkitClearResourceTimings()
        }

This is anti-social at best and anti-competitive at worst. Please engineer a solution which either stops collecting resources when the buffer becomes full (de facto industry standard) or increase the buffer size when it reaches the limit (towards an absolute maximum of e.g. 1000).

  • This isn’t an issue
  • This is a bit of an issue
  • This should be fixed asap

0 voters


#2

Thanks for sharing this with us in the community, @simonh! I have looped in the people here at New Relic who will know if this is already a known reported issue. If not, we can document it and take what we need from your use case. This is incredibly helpful—thanks again! In the meantime we can collect votes and more use cases. :blush: