Skip to content

test(interaction-harness): a long task is the page's own work - #10510

Merged
cixzhang merged 5 commits into
meta:mainfrom
vjeux:test/harness-long-task-thread-time
Nov 8, 2026
Merged

cixzhang merged 5 commits into
meta:mainfrom
vjeux:test/harness-long-task-thread-time

Conversation

@vjeux

@vjeux vjeux commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

traceRendering counted a task as long on its wall time. On a loaded runner, a proof's "no long task" claim then failed on a renderer the machine kept off the CPU: a LightboxZoom proof failed 2 of 20 runs in Chromium at four workers on two cores, each on one task of 50.4 to 51.2 ms of wall time and 11.3 to 11.7 ms of the page's own work. The README already said a claim about the page's own work judges thread time.

Intended invariant

RenderingTrace.longTasks holds the page's own tasks whose main thread ran longer than 50 ms. A task that only the wall clock stretched past 50 ms is reported apart, with both times, so nothing is dropped.

Change

  • trace.ts: longTasksOf puts a page task in longTasks when its thread time passes 50 ms, else in a new stretchedTasks list. The harness's reads stay in devtoolsTasks. A task without a thread clock reads at its wall time.
  • trace.longTasks.test.ts: the 51 ms wall / 11.5 ms thread case goes to stretchedTasks; an 80 ms wall / 60 ms thread case stays long.
  • README: a claim about a blocking wait (a synchronous request, Atomics.wait) judges stretchedTasks too.
  • The harness self-test that finds a test's own evaluate spins among the page's tasks reads both lists: a loaded machine can keep a 60 ms spin's thread under 50 ms.

Evidence

  • Failure before the change: the unit cases against main's trace.ts (227db17, NOT FOR LANDING) fail 3 of 5: the stretched task lands in longTasks, and no stretchedTasks list exists. Here they pass.
  • Eight proofs read longTasks (BottomSheetDetent, Wheel, LightboxZoom, PopoverTouchMotion, SegmentedControl, Switch, usePager and RefreshControl), each claiming the page's own work. A task stretched past 50 ms of wall time but with 50 ms or less of thread time no longer fails them; it is in stretchedTasks. PopoverTouchMotion already filtered on threadMs > 50. The threshold is unchanged.
  • Chromium, the harness spec and the eight proofs' specs (Layout or Paint, long-task and trace tests): 24 of 24 pass. At four workers on two cores, that self-test fails 6 of 6 reading longTasks alone, and passes 6 of 6 reading both.
  • The sandbox perf sampler's mountLongTaskMs sums longTasks, so its trend steps down where a task was only stretched.
  • Product/runtime behavior verified unchanged: test harness only.
  • CI impact (for a change to workflows, actions or CI scripts): none.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • Harness unit tests: 187 of 187. Prettier, ESLint 0, pnpm review:pre: 0 findings, merge into main clean.

@vercel

vercel Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 8, 2026 6:00am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 7, 2026
@astracat-bot

astracat-bot Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 8, 2026, 6:07 AM UTC

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 1e5b5b1

Storybook · Sandbox · built from this PR's head

Package size: no published package changed; no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 40 rows; run pnpm api:report.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes. The thread-time rule fixes the stretched short tasks it targets, but it moves the same load sensitivity into the harness's own long-task proof.

  • harness.interaction.browser.spec.ts:2562-2570 still expects the 60 ms timer, click and direct page spins in trace.longTasks, but under load a 60 ms wall-clock spin gets well under 50 ms of thread time and now lands in stretchedTasks, so with the renderer descheduled most of the time that test failed 2 of 2 on this branch and passed on main; asserting over [...trace.longTasks, ...trace.stretchedTasks] fixes it, and the README sentence "A test's own page.evaluate stays a long task" should say the same.

Worth a line in the description: the nightly perf sampler's mountLongTaskMs (apps/sandbox/perf/measure.ts) sums longTasks, so its trend will step down when this lands. The new unit cases fail against main's trace.ts and pass here, as described.

[Automated review]

traceRendering counted a task as long on its wall time, so a renderer
the machine kept off the CPU failed a proof's "no long task" claim with
51 ms of wall time and 11.5 ms of the page's own work. A task is now
long when its main thread ran longer than 50 ms. A task only the wall
clock stretched past 50 ms goes to stretchedTasks, with both times, so
a claim about a blocking wait still reads it.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet. It is a draft from a fork, so CI starts when it is marked ready for review with a maintainer's ci:run label on it.

The earlier request is resolved: the harness self-test now judges a test's own evaluate over longTasks and stretchedTasks, and under simulated renderer descheduling it passes where reading longTasks alone fails.

Optional follow-ups:

  • apps/sandbox/perf/measure.ts:27 could say that mountLongTaskMs picks tasks by thread time and sums their wall time.
  • PopoverTouchMotion's own threadMs > 50 filter (PopoverTouchMotion.interaction.browser.spec.ts:762) is now redundant.

[Automated review]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 7, 2026
@vjeux
vjeux marked this pull request as ready for review November 7, 2026 15:49
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 8ede760

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. CI finished with one failure that this change does not cause: the WebKit interaction leg fails "a play whose onEvent holds its lift back past the stillness interval fails by name" (harness.interaction.browser.spec.ts:434), a touch-pacing test whose result depends on wall-clock timing in touch.ts, which this pull request does not change. Re-run that leg before merging; every other check, including all six Chromium interaction legs, passes.

Since the last review this head only merges main, cleanly; the thread-time split, its unit cases and the harness self-test are unchanged, and the earlier request stays resolved.

Optional follow-ups:

  • apps/sandbox/perf/measure.ts:27 could say that mountLongTaskMs picks tasks by thread time and sums their wall time.
  • PopoverTouchMotion's own threadMs > 50 filter (PopoverTouchMotion.interaction.browser.spec.ts:746) is now redundant.

[Automated review]

@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 693864f

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not finished on this head yet.

The new head only merges main; the pull request's own changes are unchanged, and what main brought in leaves the classification and the self-test as they were. The thread-time split in longTasksOf is pinned by the new unit case, which fails against the old wall-time classification.

Non-blocking follow-ups:

  • apps/sandbox/perf/measure.ts:27 could say that mountLongTaskMs picks tasks by thread time and sums their wall time.
  • PopoverTouchMotion's own threadMs > 50 filter (PopoverTouchMotion.interaction.browser.spec.ts:746) is now redundant.
  • ChatLayoutKeyboard's Layout and Paint failure message (ChatLayoutKeyboard.interaction.browser.spec.ts:647) could list stretchedTasks too, so a task the machine stretched still shows when that test fails.

[Automated review]

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 15269bf

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not finished on this head yet.

The new head only merges main again; the pull request's own changes are unchanged, and nothing main brought in reads or writes the long-task lists. The thread-time split in longTasksOf is pinned by the new unit case, which fails against the old wall-time classification. The one failing check so far, test-node (1/4), fails in packages/cli/api/build/tree.test.mjs:293, which this pull request does not touch; main has since updated that expectation, so merging main again clears it.

Non-blocking follow-ups:

  • apps/sandbox/perf/measure.ts:27 could say that mountLongTaskMs picks tasks by thread time and sums their wall time.
  • PopoverTouchMotion's own threadMs > 50 filter (PopoverTouchMotion.interaction.browser.spec.ts:749) is now redundant.
  • ChatLayoutKeyboard's Layout and Paint failure message (ChatLayoutKeyboard.interaction.browser.spec.ts:647) could list stretchedTasks too, so a task the machine stretched still shows when that test fails.

[Automated review]

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 1e5b5b1

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not finished on this head yet.

The new head only merges main again; the pull request's own changes are unchanged, and nothing main brought in reads or writes the long-task lists. The thread-time split in longTasksOf is pinned by the new unit case, which fails against the old wall-time classification, and under a simulated loaded machine the harness self-test passes reading both lists and fails reading longTasks alone. No check has failed on this head so far.

Non-blocking follow-ups:

  • apps/sandbox/perf/measure.ts:27 could say that mountLongTaskMs picks tasks by thread time and sums their wall time.
  • PopoverTouchMotion's own threadMs > 50 filter (PopoverTouchMotion.interaction.browser.spec.ts:749) is now redundant.
  • ChatLayoutKeyboard's Layout and Paint failure message (ChatLayoutKeyboard.interaction.browser.spec.ts:647) could list stretchedTasks too, so a task the machine stretched still shows when that test fails.

[Automated review]

@cixzhang
cixzhang merged commit 10acb8c into meta:main Nov 8, 2026
77 checks passed
@vjeux
vjeux deleted the test/harness-long-task-thread-time branch November 8, 2026 06:56

This branch was successfully deployed

1 active deployment
Preview — 1e5b5b17 Deployed Nov 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants