Repository navigation
feat(website): add a slow frame log to Debug tools - #37584
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. It is an opt-in, local-only instrument that is off by default. It reuses the Debug tools lock, the storage key and the event seam the scroll inspector already uses, and it can be removed cleanly. Screenshots of this revision are attached. Notes
[DESIGN-REVIEWED] 9f80903 Description read[DESCRIPTION-READ] 3a534bc646771097b42bfe770d4f2cb12e66acf968f9b5ba2b06d2fb19784c22 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The log is a new Debug tools switch that is off by default, so nobody gets it without choosing it. A grep of What this change shipsInventory (6 items) — 6 justifiedIntent: let someone who saw the dashboard stall read, on that same machine, which interaction was slow and which script held the frame. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 9f80903 Description read[DESCRIPTION-READ] 1aac5a7de1d3f376b79e3d6d536c1ab9eb3ba95be3f3bd172839ff5c94f6fc7f That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The blind reader understood the switch, would use it, and every state the change adds appears in a screenshot. Notes
[UX-REVIEWED] 9f80903 Description read[DESCRIPTION-READ] 8f6ee6a6e1a2c8a32a7821b6889fd9a67c324abc2db4a258947fb4e05bdff7a0 That sha256 names everything this verdict read: the PR description, plus the 8 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: A person should decideWhy: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 979 lines, more than the 400 it may approve on its own. I'd approve this. It adds an opt-in slow frame log on Settings > Developer > Debug tools, and the code does what the description says.
An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
b507eea to
7f9bd79
Compare
|
|
|
|
|
Replies to the non-blocking notes on b507eea, all changed in 7f9bd79:
|
7f9bd79 to
27dffb4
Compare
|
self-added: yes
|
|
self-added: yes
|
|
27dffb4 to
0e6126a
Compare
|
self-added: yes
|
|
Red checks on 27dffb4, read from the job logs:
|
bolichen97
left a comment
There was a problem hiding this comment.
Thanks, Ray. The design is sound and well bounded: one observer, off means no observer, two capped lists, nothing leaves the tab, and the lock path stops and clears the log. I read the whole diff on 0e6126a02d and ran the four touched test files locally (slowFrameLog.test.ts, SlowFrameLogReadings.test.tsx, DebugToolsTab.storageBlocked.test.tsx, ltsFeaturePreviewsOff.test.tsx): 49 passed. All checks on this head are green.
One item blocks approval.
Blocking
-
website/src/dev/slowFrameLog.ts:139adds a regex to product code, which the team does not accept in new code:return /^https?:\/\//.test(invoker) ? fileOf(invoker) : invoker
- Cause: a new regex literal in
shortInvoker. - Consequence: it breaks the no-new-regex rule for product code, and a plain prefix check says the same thing.
- Suggested fix, same behaviour:
return invoker.startsWith('http://') || invoker.startsWith('https://') ? fileOf(invoker) : invoker
- Cause: a new regex literal in
Once that line changes I can approve on the new head.
AI-assisted, sent by Bolin Review bot
"It felt slow when I clicked" could not be answered on the machine where it happened: the dashboard read neither Long Animation Frames nor Event Timing. Settings > Developer > Debug tools gains a "Slow frame log" switch, off by default. While on, website/src/dev/slowFrameLog.ts reads long-animation-frame and event entries through one PerformanceObserver and keeps, in this tab's memory, the 20 slowest frames (each with its three longest scripts and their forced layout time) and the 20 slowest interactions (input delay, handler time, time to paint). The tab shows both lists, slowest first. Nothing is sent, stored or logged. Off, no observer exists. Turning it on asks for the entries the browser already buffered, so the log also shows what happened before the switch: every long frame, and the interactions of 104 ms and over. A build that locks Debug tools keeps it off, like the scroll inspector. When that lock arrives after the page loaded, applyConfigLocks tells the log too, so a log that was recording stops and forgets its readings. A paint time is never shown below zero: the browser rounds an interaction's duration to 8 ms and not the time its handlers ended. Both switches on the tab follow another tab's change: the new one reads the log's own state, and the scroll inspector's re-reads its key on the storage event.
0e6126a to
9f80903
Compare
|
@bolichen97 fixed in 9f80903: The existing test "shortens a module script's invoker from its URL to its file name" gains an |
bolichen97
left a comment
There was a problem hiding this comment.
Approving 9f809035b8.
- The regex is gone:
slowFrameLog.tsnow usesstartsWith('http://') || startsWith('https://'), same behaviour as before. - The new test case covers both sides: an https invoker is shortened to its file, and an invoker that only mentions a URL stays whole.
- The rest of the PR is the same as the head I reviewed earlier (range-diff shows only these two hunks after the rebase).
AI-assisted, sent by Bolin Review bot
Problem / Motivation
Goal: Someone who just saw the dashboard stall can open Settings > Developer > Debug tools, turn on a log, and read which interaction was slow and which script held the frame, on the machine where it happened.
The dashboard reads neither Long Animation Frames nor Event Timing. "It felt slow when I clicked" can today only be answered by attaching DevTools, or by a benchmark on another machine that may not reproduce it.
Why it matters
Slow frames depend on the machine, the session count and the transcript on screen. A report without the frame's script attribution cannot be acted on, and most people who see a stall will not record a performance profile.
Not a goal
What changed (motivation → approach → change)
The browser already knows what held a frame; nothing in the dashboard asked it.
website/src/dev/slowFrameLog.tsreadslong-animation-frameandevententries through onePerformanceObserverand keeps the slowest of each.mc-slow-frame-loglike the scroll inspector's flagSlowFrameLogReadings.tsxshows the first eight rows of each list, slowest first, with the count of all kept rows, while the log is onThe tab shows no single INP number. The slowest interaction leads its list, which is the page's INP while the page has had fewer than 50 interactions and the log saw them all.
Off, no observer exists and nothing is kept. Turning it on asks for the entries the browser already buffered, so the log shows what happened before the switch: every long frame, and the interactions of 104 ms and over.
main.tsximports the module, so a log left on sees the page load. A build that locks Debug tools keeps it off, as it does the scroll inspector. The lock can arrive after the page loaded (the config schema answers later):applyConfigLocksinwebsite/src/hooks/usePreviewFlagServerSync.tstells the log as well as the inspector, so a log that was recording stops and forgets its readings. Only a description of an interaction's target is kept, never the element.The switch reads the log's own state through
useSyncExternalStore, so it follows another tab that turns the log on or off. The scroll inspector's switch had a stale copy onmain; it re-reads its key on thestorageevent.The strings are in all twelve catalogs under
website/src/i18n/locales/.docs/feature-map/README.mdand the lock table indocs/system-specs/modules/platform-context.mdname the new tool and its storage key.Measurements
All numbers are mine, from one shared Linux host. A node server on 127.0.0.1 serves the built dashboard and answers
/apifromscripts/lib/stub-dashboard-api.mjswithscripts/lib/perf-fixture.mjs(222 sessions, the 100-row chat).chrome-headless-shell(Chromium 145) with no DevTools connection opens/chat?sid=perf-longcold. The page's probe observeslongtaskandpaintonly, so the one Long Animation Frame observer in the page is the log's own. Renderer CPU is read from/proc6 s afterload. Four arms interleave in each round with rotating order: main @ f5299f4, main again (A/A), this branch with the log off, this branch with the log on. 6 rounds, load 13.0-15.0. Paired per round against main, median, ms:Off and on are both inside the spread of main against itself. Compared directly in the same rounds, though, on is behind off on every row (transcript +218 ms, sum of long tasks +186 ms, renderer CPU +470 ms, 6 pairs). Six rounds on a busy host cannot settle whether that is the observer or noise, so this run does not show the log is free while on. That is why it stays off by default.
The run used the first revision of this branch, whose observer and kept lists are the ones in this revision. The run was not repeated.
Not measured: the log's cost during interaction and scrolling; Safari and Firefox (Firefox has no Long Animation Frames, and the tab says so).
Backwards compatibility
Compatible: one new switch, off by default; with it off the page creates no observer.
Removes nothing. One change to existing behaviour: the scroll inspector's switch follows another tab's change (on
mainit keeps showing the state it had when the tab mounted, while the inspector itself follows). The two tests that picked "the" switch on the tab pick the first of two.Tests
website/src/test/slowFrameLog.test.ts(15 tests) with a stand-inPerformanceObserver: off creates no observer and keeps nothing; the stored flag starts ONE observer for both entry types, buffered, with the 40 ms floor; a build that locks Debug tools and a browser with blocked storage stay off; only supported entry types are registered; frames are kept slowest first with their three longest scripts; each list is capped at 20 and drops the fastest; the entries of one interaction fold into its longest, and entries with no interaction id are skipped; the target is a description, and a press on an icon is named by the button around it; a module script's URL invoker is shortened to its file; a paint time is never below zero (fails with the clamp taken out); subscribers are told per delivery and the snapshot is stable in between; turning it off disconnects and forgets; the toggle event and another tab's storage write are followed.website/src/test/SlowFrameLogReadings.test.tsx(4 tests) renders the readings: nothing while off; each interaction row with its three parts and each frame with its scripts; the first eight rows of a longer list with the count of all of them; the notice for a browser with no long frames.website/src/test/ltsFeaturePreviewsOff.test.tsx(1 new of 24): a log that was recording stops, and drops its readings, when the Debug tools lock arrives after the page loaded. Without the dispatch inapplyConfigLocksthis test fails (checked by removing the line).website/src/test/DebugToolsTab.storageBlocked.test.tsx(6 tests): both switches render off under blocked storage; the new switch stores the flag, announces it both ways, and shows the readings only while on; each switch follows another tab's storage write, and one press then turns the tool off.website/src/i18n/style/withI18N_BASE_REFset (126 tests); the repo's related frontend set (scripts/run_scoped_tests.py --surface frontend);npm run i18n:pseudowith no diff;npm run i18n:check;lint:i18n;tsc -p tsconfig.app.json; eslint on the changed files; the analyze build with the bundle-size and chunk-cycle gates;gen:ui --check; the theme-colour, phantom-class and restyle gates. All pass.Manual verification
In the built dashboard (stubbed API, headless Chromium 145), with a page handler that holds each press for 80 ms:
A second pass opened a chat, the session options menu and typed in the composer: the tab listed the menu press as
button [Session options]with its handler time, the key presses, and the page-load frames with the React and module scripts that held them. Not verified: Safari, Firefox, a phone, a real gateway.Screenshots / video
All from the build of 0e6126a, dark theme unless named. The one product line that differs in this revision (
shortInvokerchecks the URL prefix withstartsWith) renders the same text.Log turned on in the tab, then a chat, a menu and typing: the slow interactions and the long frames:
Log on since the page loaded, after three presses a page handler held for 80 ms:
Log on in a browser that reports neither entry type: the empty state and the notice (the capture overrides
PerformanceObserver.supportedEntryTypes):Light theme, and the tab with the log off
Related Issues
N/A. From the Chrome modern-web-guidance review of the dashboard (identify-heavy-scripts, identify-inp-causes, interaction-paint-timing).
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.