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).

Active route
2D
rAF p50 / p95
idle
Paint / mutation
idle
changedElements
idle
Long frames (>50 ms)
idle

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
  1. Build 16 sibling cards and mutate 1 per frame. Each card carries drawable inside a canvas so e.changedElements counts sibling invalidation.
  2. 2D route: 5-argument drawElementImage() in CSS pixel units. Backing dimensions track device-pixel-content-box and only reassign when changed.
  3. WebGL route: ElementGL uploads only changed cards. Each card uploads with texElementSubImage2D() and registers its box with updateElementGeometry().
  4. 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