Subtree complexity
I wanted to know which HTML and CSS features inside a drawable subtree trigger disproportionate paint-record rebuilds or post-main-thread raster stalls, and whether contain: layout paint or contain: strict cuts the cost. Pick a workload and backend below, or run the full sweep across all nine workloads on your device.
Idle. Flat baseline mounted statically on 2D canvas (no animation running).
Measured runs
| Workload | Backend | contain | Mutation | FPS | p50 ms | p95 ms | JS ms | LoAFs (script / style+layout / after main) | Paint / mut | changedElements (mean / max) |
|---|---|---|---|---|---|---|---|---|---|---|
| No benchmark runs yet. Press "Benchmark active workload" or "Run full matrix". | ||||||||||
Containment delta
| Workload | Backend | Compared mode | Base p95 ms | Contained p95 ms | p95 delta | changedElements delta |
|---|---|---|---|---|---|---|
Run a workload benchmark or the full matrix to compare contain: layout paint and contain: strict against contain: none. | ||||||
Show the code the workloads, 2D and WebGL paint handlers, and the frame/LoAF timer
- Build 16 sibling cards and mutate 1 per frame. Each card carries
drawableinside a canvas soe.changedElementscounts sibling invalidation. - 2D route: 5-argument
drawElementImage()in CSS pixel units. Backing dimensions trackdevice-pixel-content-boxand only reassign when changed. - WebGL route:
ElementGLuploads only changed cards. Each card uploads withtexElementSubImage2D()and registers its box withupdateElementGeometry(). - Frame timer and Long Animation Frames breakdown. Splits frames over 50 ms into script, style/layout and post-main-thread presentation time.
How it works
Every workload renders 16 sibling cards in a 4 by 4 grid. On the plain DOM route the grid sits directly in the stage. On the 2D and WebGL routes the grid sits inside a single <canvas content="drawable" layoutsubtree>, and each of the 16 cards carries its own drawable attribute. On every animation frame during a timed run, the script mutates only 1 of the 16 cards (cycling through cards 0 to 15) without forcing requestPaint(), so Chromium decides which siblings need fresh paint records.
The 2D handler draws all 16 cards with 5-argument drawElementImage(card, x, y, w, h) after scaling the context to device pixels. The WebGL handler opens one context via ElementGL from /lib/element-gl.js, reads e.changedElements on each paint event, re-uploads only the listed cards with gl.texElementSubImage2D(), draws all 16 quads, and calls canvas.updateElementGeometry() whenever a card box changes.
Each timed run warms up for 4 frames, resets counters, then measures for about 600 ms (at least 14 frames). A PerformanceObserver watches long-animation-frame entries over the same window and splits every frame over 50 ms into script time (renderStart to styleAndLayoutStart), style and layout time (styleAndLayoutStart to end of main-thread work), and post-main-thread raster and presentation time (end of frame to presentationTime). When a full sweep finishes, the page sends a compact summary to window.__gfx.report('perf-subtree', ...) and formats a Markdown table you can copy.
Live checks
The checks below wait for a tap so loading this page doesn't open a WebGL context or disturb the stage. Each check builds its own isolated fixture in a hidden test stage and retires its canvas when finished.
Findings
- Not verified on real hardware yet. This page was built on 2026-11-26 and hasn't been timed on a real phone or desktop GPU yet. Press "Run full matrix" on Chrome with
#canvas-draw-elementenabled, then copy the Markdown table or inspectnpm run reportsto record measured numbers. - Why 16 separate
drawablesiblings matter. Puttingdrawableon each card lets the WebGL path skiptexElementSubImage2D()for the 15 unchanged cards whene.changedElementsnames only the mutated sibling. Any over-invalidation shows up aschangedElements > 1and immediately multiplies texture uploads. - Containment requires definite card sizes for
contain: strict. The 4 by 4 grid fixes each track at 78 px tall socontain: none,contain: layout paintandcontain: strictkeep the same card geometry while isolating internal layout and paint bleed. - Long Animation Frames only appear above 50 ms. Fast workloads on a desktop GPU will report
0 (<50 ms)LoAF entries; on a phone or under heavy blur, shadow and SVG filter stacks, post-main-thread presentation stalls show up in the third column of the LoAF split.