Skip to content

Commit

Permalink
Avoid setTimeout in waitOnElement (WebKit#321)
Browse files Browse the repository at this point in the history
waitOnElement uses a 50ms timeout, which was historically motivated by FlightJS that used requirejs which had a hard-coded 50ms pause.

We've observed fragile CPU scaling behavior with this approach in Speedometer 2.1. V3.0 is less affected by this since the perf-dashboard is the only workload the regularly needs another cycle to wait (all other workloads are ready after onload has fired).

Using rAF lowers the timeout limit and is more realistic in required CPU ramp-up performance.
  • Loading branch information
camillobruni committed Nov 20, 2023
1 parent 2ee210c commit 208e1ab
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions resources/benchmark-runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ class Page {
return new Promise((resolve) => {
const resolveIfReady = () => {
const element = this.querySelector(selector);
if (element) {
window.requestAnimationFrame(() => {
return resolve(element);
});
} else {
setTimeout(resolveIfReady, 50);
}
let callback = resolveIfReady;
if (element)
callback = () => resolve(element);
window.requestAnimationFrame(callback);
};
resolveIfReady();
});
Expand Down

0 comments on commit 208e1ab

Please sign in to comment.