Interactions with the Back-forward cache?
You may want to reference this from the BFCache meta bug: https://github.com/whatwg/html/issues/5880 +CC @rakina
I was wondering what kind of interation this feature will have with the Back-forward cache. For instance, what happens exactly in the following scenario:
- The document create a:
const profiler = new Profiler({
sampleInterval: 10, // Target sampling every 10ms
maxBufferSize: 10 * 100, // Cap at ~10s worth of samples
});
- The user navigate the main frame elsewhere. The old document enters the BFCache.
- The user navigates back. The cached document is re-activated.
- The re-activitated document calls:
const trace = await profiler.stop();
What kind of data trace contains?
You may want to figure out what is the expected behavior and add some tests about this.
When the document enters the BFCache, it's task runners are frozen, so I guess the trace shouldn't include any samples from when it was cached?
When the document enters the BFCache, it's task runners are frozen, so I guess the trace shouldn't include any samples from when it was cached?
Indeed, this is the behaviour recommended by the spec:
The user agent is RECOMMENDED to pause the sampling of a profiling session if the browsing context is not in the foreground.
Though, this is not required. The Blink implementation for example does not enter the paused state when this occurs, and instead records empty samples for the time that the context/realm is not current (as per the results of executing the take a sample algorithm on a foreign realm).
Perhaps we should consider requiring implementations to pause sampling in this case? I can't think of any cases where the empty sampling would be useful.
Perhaps we should consider requiring implementations to pause sampling in this case? I can't think of any cases where the empty sampling would be useful.
This sounds reasonable. @acomminos, do you think we can update the spec to listen to "fully active" status changes (guide)?