Input latency and hit-testing
I wanted to know how much Interaction to Next Paint (INP) delay HTML-in-canvas adds when you tap, drag or type into moving controls, and what calling updateElementGeometry() plus the attribute-toggle workaround costs per frame across 1 to 200 elements. Tap or drag the moving buttons, type in the moving text box, and run the sweep below to measure overhead and hit-test drift on your browser.
Starting arena…
| Mode | Events | INP p75 | INP p98 | Worst | Input | Proc | Pres | Hit accuracy | Stale misses |
|---|---|---|---|---|---|---|---|---|---|
| Tap buttons, drag them or type in the moving input above to record real Event Timing entries. | |||||||||
Recent recorded interactions (last 10)
| Event | Mode | Controls | Target | Input | Proc | Pres | Total |
|---|---|---|---|---|---|---|---|
| None recorded yet. | |||||||
Show the code arena drawing, geometry updates, Event Timing and sweep
- 2D canvas mode. Draws each control with explicit width and height on
drawElementImage(). - WebGL mode with and without cache busting. One
ElementGLcontext draws quads, callsupdateElementGeometry(), and togglesdata-hitin the cache-bust mode. - Real-interaction INP recorder. Watches
PerformanceObserver({ type: 'event', durationThreshold: 0 })and splits input delay, processing and presentation delay. - Automated 1 to 200 control sweep. Measures per-frame JS cost, Long Animation Frames and
elementsFromPoint()hit accuracy across each route.
Geometry overhead and hit-test drift sweep
The live arena measures real taps and typing. This sweep runs 24 frames per step across 1, 12, 50, 100 and 200 moving controls on an isolated fixture canvas, timing the per-frame JavaScript work, counting Long Animation Frames over 50 ms, and probing document.elementsFromPoint() after moving controls to test whether Chromium's hit-test cache went stale.
| Controls | Route | JS median | JS p95 | Geometry loop | Frame median | LoAFs (>50 ms) | elementsFromPoint() hits |
|---|---|---|---|---|---|---|---|
| Press "Run overhead sweep" to measure this browser. | |||||||
How it works
The arena puts N moving buttons and one moving text input through four paths: plain DOM moved with CSS transform: translate3d(), a 2D drawable canvas calling drawElementImage(el, x, y, w, h), and one WebGL 2 ElementGL context calling updateElementGeometry() either alone or paired with el.toggleAttribute('data-hit').
In Chromium 157 and Canary 160, moving a drawable element's geometry with updateElementGeometry() after the browser has already hit-tested it can leave Chromium's hit-test cache pointing at the old rectangle until a DOM attribute or style change invalidates it. The third mode leaves that toggle off on purpose so you can see and measure stale misses and ghost hits. The fourth mode turns the toggle on so you can measure what invalidating 1 to 200 elements every frame costs in JavaScript time, style recalculation and Long Animation Frames.
Every tap, drag and keypress inside the arena is observed with PerformanceObserver({ type: 'event', durationThreshold: 0 }). Each entry is split into input delay (processingStart - startTime), processing duration (processingEnd - processingStart) and presentation delay (startTime + duration - processingEnd). Chromium rounds Event Timing duration to 8 ms steps for privacy, so presentation delay is clamped at zero when rounding pulls the total slightly under processingEnd. On every pointer down, the page compares your pointer coordinates against the drawn control rectangles and document.elementsFromPoint() to count exact hits, stale misses and ghost hits at old positions.
Live checks
These checks build their own fixtures on the hidden test stage and wait for a tap so loading this page never opens a WebGL context or runs a benchmark loop unasked.
| Status | Check | Detail |
|---|
Findings
- Not verified yet on real hardware or headless Chromium: this page was built on 2026-11-26 and its live INP and 1 to 200 control sweep numbers haven't been collected from desktop Chrome or my Android phone yet. Open the page in Chrome with
#canvas-draw-elementenabled, tap and type across all four modes, run the sweep, and use Copy Markdown to record the results infindings/perf-inp.md. - Why the cache-bust mode is tested separately: earlier experiments in this repository (recorded in
/crashes/and/friction/on Chromium 157 and Canary 160) hit a stale hit-test cache whenever a drawn element moved without an attribute toggle. Toggling an attribute on every moving control clears that cache, which may also trigger per-frame style invalidation and extra paint work as control counts rise toward 200. - Coordinate scaling at high device pixel ratios:
updateElementGeometry()takesgeometryUnit()from/lib/surface.jsso the WebGL hit boxes line up on a 2.625 DPR Android screen as well as at 1x desktop scale. - Open items that need a real phone: touch drag responsiveness, software keyboard and IME typing latency inside the moving canvas input, and whether 200 attribute toggles per frame push mobile frame times past 50 ms LoAFs.