GoogleChrome / lighthouse

Automated auditing, performance metrics, and best practices for the web.
https://developer.chrome.com/docs/lighthouse/overview/
Apache License 2.0
28.23k stars 9.35k forks source link

Take into account `scheduler.yield()` #16183

Open connorjclark opened 1 week ago

connorjclark commented 1 week ago

scheduler.yield() is here.

AFAIU, this is a better version of navigator.scheduling.isInputPending() (which LH also does not handle https://github.com/GoogleChrome/lighthouse/issues/11747).

We can handle this pretty simply, I think:

  1. Emit a trace event when await scheduler.yield() happens
  2. When simulating long tasks for mobile, use these trace events as the bounds for "synthetic" tasks, and check if those are larger than the long task threshold rather than the original-task-multiplied-by-cpu-throttling

This should fairly reduce TBT for pages that properly use scheduler.yield.

We may wish to prioritize this in order to give people trying this new feature out in Origin Trials, and using Lighthouse to help evaluate its impact, will get a good representation of its effectiveness.

brendankenny commented 1 week ago

people trying this new feature out in Origin Trials

FYI the origin trial is over and scheduler.yield is shipping in m129 (currently in beta).

Plan seems workable for tasks as LH has defined them, though more difficult in an animation-frame-based future. OTOH might not matter as much by then since it only matters for simulated throttling.