Compute pressure fallback

I wanted to know if PressureObserver can step a live drawable canvas down from a WebGL shader to a 30 fps 2D canvas, then an on-demand 2D canvas, and finally plain HTML via moveBefore() without dropping what you typed. Type in the card below, then switch pressure tiers or burn CPU briefly to watch the backend change underneath it.

Pressure tier fair (startup)
Active backend 2D (30 fps)
Live FPS 0 fps
Canvas memory 0.0 MB
Transition time 0.0 ms
fair · 2D 30 fps

Adaptive surface control card

Edit the text, drag the slider or toggle effects while changing tiers above.

50% load 30 fps 2D

30 chars · 3 toggles on · waiting for input

Checking PressureObserver…

Show the code the card markup, the WebGL shader, the 4-tier handoff, the PressureObserver wiring
  1. The interactive card. Plain HTML inside #card-host, moved into a WebGL or 2D canvas and back out again with moveBefore().
  2. The nominal WebGL shader. Chromatic RGB glass dispersion, animated ripple distortion and specular sheen over the live element texture.
  3. The four-tier handoff. Stepping between ElementGL, 30 fps 2D, on-demand 2D and plain DOM while retiring replaced canvases via window.__gfx?.retire().
  4. PressureObserver and manual override. Subscribing to cpu pressure samples at 1,000 ms intervals and feeding the tier switcher.

How it works

The card starts as ordinary HTML in #card-host, then upgrades to the fair 2D route on load so the page doesn't open a WebGL context before it's needed. When PressureObserver reports a CPU state (or when you pick a tier in the selector), the stage hands the same <article> element between backends using moveBefore().

TierBackendFrame budgetWhat changes
nominal WebGL 2 via ElementGL 60 fps while on screen Uploads the card with texElementSubImage2D() only when it changes, draws chromatic glass refraction and ripple distortion, and keeps hit boxes aligned with updateElementGeometry().
fair 2D canvas via drawElementImage() 30 fps throttled Disposes the WebGL stage, moves the card into a 2D canvas and retires the WebGL canvas with window.__gfx?.retire(). Draws a light tilt and drifting highlight with a 5-argument drawElementImage() call.
serious 2D canvas on-demand 0 idle frames Stops the requestAnimationFrame loop completely. The canvas paints only when Chromium fires a paint event (for example when you type, drag the slider or press a toggle).
critical Plain HTML 0 frames, 0 canvases Calls moveBefore() to lift the live card straight back into #card-host, removes drawable and retires the canvas so canvas memory drops to 0.0 MB while your text and controls stay intact.

Pressing "Burn CPU briefly (1.5 s)" spawns up to four short-lived Web Workers (falling back to chunked main-thread work if workers are blocked) for 1.5 seconds so you can push real CPU load without locking the page. Any continuous animation pauses automatically when the stage leaves the viewport or the tab is hidden, and stops animating when prefers-reduced-motion: reduce is set.

Live checks

These four checks run on isolated fixtures in the corner of the window, never on the card above. Because two of them create a WebGL context and wait for canvas retirement, they wait for a tap.

Findings