什么时候“开始配置并重新加载页面”决定停止自动记录?

Drk*_*ima 3 devtools performance-testing google-chrome-devtools

我在Chrome DevTools中大量使用了性能时间表来捕获页面的性能记录。

大多数情况下,我使用“开始配置和重新加载页面”,该页面会自动开始和停止记录。

问题是:DevTools何时决定停止记录

我注意到,它总是继续在“加载”事件之后至少记录几百毫秒,并试图找出页面何时变为“大部分空闲”。

但这是一个模糊的猜测。我想知道它是否依赖于某些表演事件(例如在Lighthouse中的“互动时间”中使用的那个事件)?

wOx*_*xOm 7

目前,它等待的三个load事件
没有记录,因此将来可能会更改,恕不另行通知。

this._millisecondsToRecordAfterLoadEvent = 3000;
Run Code Online (Sandbox Code Playgroud)
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();
}
Run Code Online (Sandbox Code Playgroud)

  • 您可以通过在 [devtools-on-devtools](/sf/answers/2884151161/) 中运行以下代码来修改当前调试会话中的 devtools 代码:`UI.panels.timeline._millisecondsToRecordAfterLoadEvent = 9001`(主开发工具应该有时间轴面板处于活动状态)。 (2认同)
  • @wOxxOm 这真的很有帮助!检查了最新的chrome版本109,看起来默认值更改为5000,并且变量名称更改为UI.panels.timeline.millisecondsToRecordAfterLoadEvent (2认同)