Backend scaling: 2D, WebGL2, WebGPU and a shared-GL copy bridge

I wanted to know where the crossover points sit when you scale up live HTML elements in a canvas across all four drawing routes: 2D drawElementImage(), WebGL2 texElementSubImage2D(), WebGPU drawElementImageToTexture(), and a 2D-to-shared-WebGL copy bridge. Pick a configuration or run a sweep below to measure frame times, upload cost, GPU timers and Long Animation Frames on your device.

Initialising benchmark...

Show the code the four backend loops and timing hooks
  1. 2D route: draws every tile with 5-argument drawElementImage(el, 0, 0, w, h) under a per-tile affine transform inside paint.
  2. WebGL2 route: uploads dirty tiles through ElementGL.upload() (texElementSubImage2D()), shades all quads with one context and calls updateElementGeometry().
  3. WebGPU route: uses the shared device from /shared/backend.js, uploads dirty tiles with GPUElementTexture.update() (drawElementImageToTexture()) and draws every quad in one render pass.
  4. Shared-GL copy bridge: draws dirty tiles on a drawable 2D canvas, copies each tile into a shared ElementGL texture via texSubImage2D(), shades all quads and composites back with drawImage().
  5. Timers: Long Animation Frames breakdown plus optional EXT_disjoint_timer_query_webgl2 polling.

Backend Count Tile Dirty FPS p50 / p95 / p99 (ms) Upload (ms) Draw (ms) GPU timer LoAFs (script/style/post)
No measurements yet.

After a backend sweep or full matrix completes, the page queues a compact summary to /api/reports (nothing is sent from localhost) so results from phones and desktop GPUs can be compared later. LoAF columns show frames over 50 ms split into script, style/layout/paint and post-main-thread presentation delay.

How it works

Every route draws the same grid of live HTML cards at native devicePixelRatio, applying a per-tile wave, rotation and shear transform so the GPU routes and the 2D route do matching geometric work. Tiles that mutated on a frame also flash a warm orange tint, so you can tell at a glance whether 0%, 10% or 100% of elements are re-uploading.

JS upload and total draw times come from performance.now() around the upload calls and frame callback. Where available, WebGL2 queries GPU elapsed time with EXT_disjoint_timer_query_webgl2, and WebGPU uses timestamp-query when the shared device enables it, falling back to queue.onSubmittedWorkDone() latency otherwise. Main-thread stalls over 50 ms are broken down with a long-animation-frame observer.

Live checks

These checks create WebGL2 and WebGPU fixtures and read pixels back to verify rendering, so they wait for a tap instead of running on load.

StatusCheckDetail

Findings