v153 · loaf in workers

The workaround, and what it cannot tell you

There is a way to notice a blocked worker from inside it: reschedule a task continuously and watch for one that runs late. It works, it costs almost nothing, and comparing what it produces against a real Long Animation Frame entry shows exactly what is missing.

Worker entries need a launch flag. LongAnimationFrameWorker has status "test" in Chromium's runtime_enabled_features.json5 (Chrome 153 through current main), so there is no chrome://flags entry and --enable-experimental-web-platform-features does not turn it on. Relaunch Chrome or Canary with --enable-blink-features=LongAnimationFrameWorker. Even then, Chromium reports a worker entry only for a congested moment: a task was already waiting while another ran, the backlog lasted at least 200ms, and the worker then went idle for more than 5ms (animation_frame_timing_monitor.cc). A long task with nothing queued behind it produces no entry.

Block the worker, then compare the two records

What the worker's self-timing noticed
#blocked forat
Not run yet.
Press the button.

The self-timer is nine lines: a setTimeout(…, 16) that reschedules itself and records any gap over 50ms. That is the entire workaround, and its total cost is one small task every 16ms. (A 0 delay would also work, but its clamped 4ms chain never lets the worker go idle, which in Chromium keeps a congested moment open and delays the real entry.) While the worker is blocked, this page keeps posting it a message every 40ms, as a busy app would; that queued work is what Chromium's worker implementation reports.

Field by field

A real long-animation-frame entry against what a self-timer can produce
fieldthe entrythe workaroundwhy it matters

The workaround in full

// Inside the worker.
let lastTaskEnd = performance.now();
const tick = () => {
  const now = performance.now();
  const gap = now - lastTaskEnd;
  if (gap > 50) report({ blockedFor: gap, at: now });
  lastTaskEnd = performance.now();
  setTimeout(tick, 16);
};
setTimeout(tick, 16);

Note what it measures: the gap between one of its own tasks and the next. If a single task blocks for 400ms, the gap is 400ms and the timer is correct. If four tasks each block for 100ms with the timer running in between, the timer reports nothing at all — every individual gap is under the threshold, and the worker was still unresponsive for 400ms.

see also