catchpoint / WebPageTest.agent

Cross-platform WebPageTest agent
Other
213 stars 138 forks source link

Add support for Soft Navigation #603

Open tkadlec opened 1 year ago

tkadlec commented 1 year ago

Chrome is experimenting with support for Soft Navigations, which would make it possible for folks to see Core Web Vitals (and other page lifecycle metrics) for single-page applications. https://developer.chrome.com/blog/soft-navigations-experiment/

This would be awesome to support because right now testing SPA's in WebPageTest with multi-page steps means we can't provide those metrics.

There are a few things we could use here:

One is to look for soft-navigation events in a Performance Observer like so:

const observer = new PerformanceObserver(console.log);
observer.observe({ type: "soft-navigation", buffered: true });

The other is to look at the trace events the Chrome team was kind enough to add: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/timing/soft_navigation_heuristics.cc;drc=0c4306fc554c80506eb0f9b833a5d2a5fdd452d5;l=204

pmeenan commented 1 year ago

Enabling it with --enable-experimental-web-platform-features globally might be risky because that triggers a bunch of other features too. Could be useful for a one-off. Let me poke around and see if there is a blink-specific feature flag that can be enabled with --enable-blink-features= instead.

pmeenan commented 1 year ago

I'll need to double-check but I think --enable-blink-features=SoftNavigationHeuristics should turn just that feature on. @yoavweiss do you know for sure? I can't remember if that can be used for all of the runtime_enabled_features or each one needs to be plumbed specifically.

tkadlec commented 1 year ago

I also don't mind if our initial support is a bit more experimental for sure. Like...something you have to opt into until it stabilizes a bit, but let's see what the wise Mr. @yoavweiss has to say. :)

yoavweiss commented 1 year ago

--enable-blink-features="SoftNavigationHeuristics,NavigationId" should work, I think.