When does “Start profiling and reload page” decide to stop the automatic recording?

风流意气都作罢 提交于 2019-12-06 07:50:03

问题


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)?


回答1:


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();
}


来源:https://stackoverflow.com/questions/54278305/when-does-start-profiling-and-reload-page-decide-to-stop-the-automatic-recordi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!