I use the Performance Timeline in Chrome DevTools quite a lot to capture performance recordings of my page.
Most of the time I use the "Start profiling and reload page", which automatically starts and stops the recording.
The question is: When does DevTools decide to stop the recording?
I've noticed that it always continues to record at least a few hundred ms past the "Load"-event and tries to figure out when the page has gone "mostly idle".
But that's quite a fuzzy guess. I'd love to know if it relies on some performance event (like the one used in "time to interactive" in Lighthouse)?
Currently it waits for three seconds after load
event.
This is not documented so it may change in the future without notice.
this._millisecondsToRecordAfterLoadEvent = 3000;
async _loadEventFired(event) {
if (this._state !== Timeline.TimelinePanel.State.Recording || !this._recordingPageReload ||
this._controller.mainTarget() !== event.data.resourceTreeModel.target())
return;
const controller = this._controller;
await new Promise(r => setTimeout(r, this._millisecondsToRecordAfterLoadEvent));
// Check if we're still in the same recording session.
if (controller !== this._controller || this._state !== Timeline.TimelinePanel.State.Recording)
return;
this._stopRecording();
}