Repository navigation
Read the busy fade on the animation's clock rather than on a deadline from the press - #241
Merged
Merged
Conversation
test_a_wait_the_reader_would_notice_says_so_and_a_short_one_says_nothing timed its samples from performance.now() taken just before the press and asked that every frame past 400ms had settled at 0.5. The rule is 200ms of delay and 140ms of fade, but that clock only starts at the first frame the busy attribute is painted in, and the press does the layer's own work — control render, margin update — before that frame arrives. Locally the fade lands at 383ms, 17ms inside the deadline; on the nightly runner the first frame is about 120ms late and the samples past 400ms are still mid-fade. Each frame now records the animation's own currentTime and playState beside the opacity. The delay is read as the frames before currentTime reaches 150ms, including the ones before the animation exists, and the fade as the frames the animation itself reports finished, so the reading consumes a fact the page states rather than a deadline it has to beat.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The nightly leg of
cifailed on run 33726571939 (e71fa11) with ten cases. Nine are already owned by open PRs — four by #236 (test_a_widgets_label_takes_a_comment_inside_the_control_it_labels,test_a_selection_around_a_targets_buttons_does_not_deaden_them,test_a_closed_leaf_clears_itself_off_the_tray,test_the_leaves_tray_takes_the_keyboard), four by #239 (test_every_passage_in_a_real_page_can_be_quoted[feature-gallery], both parameters oftest_ask_addresses_follow_the_feature_gallery_s_visible_margin_controls,test_the_shipped_long_thread_opens_beside_its_source_in_the_right_margin), and the ring walk by #239'sship-reviewprecondition ahead of #236 and #240. The tenth is unowned and is what this takes:test_render_widgets.py::test_a_wait_the_reader_would_notice_says_so_and_a_short_one_says_nothing, first seen on this run and absent from the three nightlies before it (33722764498, 33718675826, 33714432132).The test took
performance.now()just before the press and asked that every frame past 400ms had settled at 0.5. The rule it reads is[aria-busy="true"] { animation: … 140ms linear 200ms both; }— 340ms in all — but that clock starts at the first frame the busy attribute is painted in, not at the press.#inFlightsets the attribute synchronously and then renders the controls and updates the margin in the same task, so the animation's start time is the first frame after all of that. Measured here, the fade begins at 233ms and completes at 383ms: 17ms inside the deadline. The reported sample is that whole timeline slipped about 120ms, which is what a loaded nightly worker costs — the frames past 400ms are still mid-fade rather than absent.Solution
Read the fade on the rule's own clock. Each sampled frame now records the animation's
currentTimeandplayStatebeside the opacity. The delay is the frames beforecurrentTimereaches 150ms, including the ones before the animation exists at all; the fade is the frames the animation itself reportsfinished. Both halves of the claim survive intact — nothing paints while the wait is too short to notice, and the wait that is long enough ends at 0.5 — and neither is a deadline the machine has to beat. This istests/CLAUDE.md's A wait consumes a fact the system states applied to a reading that was inferring from elapsed time, using thegetAnimations()route that section names.The sampling window goes 500ms → 700ms so a start that slips still leaves frames on the far side of the fade; it is a bounded
setTimeoutinside the page, not an awaitedanimation.finished.Testing
uv run pytest tests/test_render_widgets.py --run-nightlyis green on this branch (82 passed) anduv run pytest testswas green (808 passed, 6 skipped) on the commit the run failed on.ruff checkandruff formatat the pinnedv0.16.1pass on the changed file.Not vacuous, checked from both sides against the rule in
chrome-style.js:The two negations
… 140ms linear 0ms both(delay removed)the wait was announced before it was one: {1, 0.94, 0.88, …}— the early halfa wait worth noticing said nothing: []— the late halfThe frame samples, before and after
Sampled locally under three spinning cores, on the original wall clock (
ms since t0, opacity):The fade runs 223→383. The assertion's threshold is 400, so the margin the reading had was one frame. On the animation's clock the same run reads
currentTime0 at the frame the attribute paints in, 200 where the fade starts and 340 where it ends and holds — the same numbers the rule is written with.Worth a maintainer's eye rather than a fix here: about 120ms of main thread between the press and the frame the busy attribute paints in is a lot for
SUGGESTION_PAGE, which is a small fixture.#inFlightcalls#renderControlsandthis.#margin?.update()after setting the attribute, and the animation cannot start until both have finished. The rule is designed for exactly the heavy-page case, so it still does the right thing for the reader — but the cost is the layer's, and it is not visible from any assertion that reads the rule alone.Automated fix for failed run