Skip to content

Commit deebbe2

Browse files
committed
fix: make the ticker's changing region an ELEMENT, not a run of glyphs
The round trip -- fail, parse the message's own suggestion, apply it, page must then be stable -- failed on three separate CI runs with three unrelated regions for the same page: [216,52,216,65] 1 column [62,50,219,67] 157x17 [71,51,71,68] 1 column The diagnosis was right every time. What it was diagnosing would not hold still. Ten random glyphs are a bad thing to measure. Their extent depends on which characters came up, and a capture on a slower machine can land mid-repaint and see a single column of a single character -- hence regions ranging over two orders of magnitude. Pinning the font to monospace (previous commit) fixed the extent but not the mid-repaint sliver, so it was necessary and not sufficient. Now every tick paints the box a RANDOM colour. Two attempts then differ across the whole element at high contrast, a partial repaint is still an unmistakable diff, and the region is the element -- which `position: absolute` with a fixed width and height pins exactly. Random, specifically, and not a black/white toggle: a two-state flip depends on parity, and two attempts ~100ms apart are an unpredictable number of 30ms ticks apart, so they can land on the SAME phase. Measured -- with the toggle the region came back as [69,50,210,66], the text again. Measured after: eight consecutive local runs, all green, every one reporting [40,40,239,79] -- 1.62% of the 800x600 image, changed in 4 of 4 pairs which is the CSS box (left:40 top:40 200x40) to the pixel. Before this change no two runs agreed. This is also the honest shape of what the fixture stands in for: a clock or spinner repainting inside a box that does not move, which is exactly the case where `skip_area` is the right answer. `rake test` and standardrb below.
1 parent f6de686 commit deebbe2

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

test/fixtures/app/index-with-ticker.html

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,32 @@ <h1>Ticker</h1>
4242
<div id="ticker">0000000000</div>
4343

4444
<script>
45+
// Same box, different pixels, forever -- but the CHANGE HAS TO BE THE WHOLE
46+
// BOX, not the glyphs inside it.
47+
//
48+
// Glyphs were the first attempt and they are unreliable to measure: a capture
49+
// on a slow machine can land mid-repaint and see a single column of a single
50+
// character, so the reported region came out anywhere from 1x17 to 157x17 for
51+
// the same page (runs 32750597989, 32752142873, and the selenium_headless cell
52+
// of the third). The diagnosis was right every time; what it was diagnosing
53+
// would not hold still.
54+
//
55+
// Inverting the whole box changes ~8000 px at maximum contrast, so a partial
56+
// repaint is still an unmistakable diff, and the region is the ELEMENT --
57+
// which `position: absolute` with a fixed width and height pins exactly. That
58+
// is also the honest shape of the real thing this stands in for: a clock or
59+
// spinner repainting inside a box that does not move.
60+
// A RANDOM colour, not a two-state toggle: alternating black/white depends on
61+
// parity, and two attempts ~100ms apart are an unpredictable number of 30ms
62+
// ticks apart, so they can land on the SAME phase -- identical background,
63+
// only the glyphs differing, and the measured region collapses back to text.
64+
// Verified locally: with a toggle the region came out [69,50,210,66] (text),
65+
// with a random colour it is the element.
4566
const retick = () => {
46-
// Same box, different pixels, forever. Every character changes, the way a
47-
// spinner or a re-rendered clock does -- a counter where only the last
48-
// digit moves would make the measured region a single glyph, which is a
49-
// property of THAT page, not of unstable pages.
50-
document.getElementById("ticker").textContent =
67+
const el = document.getElementById("ticker")
68+
const channel = () => Math.floor(Math.random() * 256)
69+
el.style.backgroundColor = `rgb(${channel()}, ${channel()}, ${channel()})`
70+
el.textContent =
5171
Array.from({length: 10}, () => "0123456789ABCDEF"[Math.floor(Math.random() * 16)]).join("")
5272
}
5373
retick()

0 commit comments

Comments
 (0)