@vectorvesper/motionCore Engine · Quality Tier Governor

AdaptiveQuality

Static device heuristics guess instantly but never learn, while frame budgets measure reality only after frames accumulate. AdaptiveQuality fuses hardware capability detection (GPU unmasked renderer, WebGL2, CPU cores, memory) as an unbreakable floor with live conductor frame telemetry and attribution pressure, preventing the oscillation loop on underpowered hardware.

The AdaptiveQuality governor determines how much visual detail your application should render at any given moment. It combines static hardware detection (GPU tier, WebGL2 availability, memory, CPU concurrency) with live AnimationBudget frame telemetry, attribution pressure diagnostics, and accessibility preferences.

The device tier acts as an unbreakable floor. Live frame telemetry can reduce quality under heavy load, but never lifts it above what the hardware can sustain. Without that floor, low-end devices enter an endless oscillation cycle: quality degrades, frames recover because quality dropped, quality upgrades, severe jank resumes, and quality degrades again.

Every state reading carries a machine-readable cause string (such as "device", "render", "held", or "reduced-motion"). Branch on cause when you need to distinguish between an underpowered GPU and transient main-thread pressure.

Hardware Floor & Main-Thread Load Fusion

Hardware Floor+ AnimationBudget Telemetry= Effective Tier
Demo loads on scroll

Quick start

Map the effective tier to a quality settings dictionary once, then pass it to your renderer.

Tier changes are rare: governed by the static hardware floor plus asymmetric hysteresis. It is designed for conditional rendering, not per-frame mutations.

Quality Cause Taxonomy & Attribution Matrix

Every reading returns a machine-readable cause explaining why the tier is in its current state.

CauseMeaningArchitectural Action
"ok"Hardware capable and frames landing smoothly on time.Run complete intended high-fidelity visual experience.
"device"Hardware floor actively capping fidelity (e.g. mobile GPU or low RAM).Quality stays at device floor even if current frames are idle.
"frame-rate"Capable device suffering frame drops without attributed cause.Trusts the AnimationBudget and steps down one quality tier.
"render"Attribution engine proves rendering/GPU is the true bottleneck.Reducing scene complexity will directly restore frame rate.
"held"Frame drops caused by third-party main-thread blocking.Quality is held steady; shedding graphics would not speed up third-party scripts.
"reduced-motion"User prefers-reduced-motion media query is active.Tier is forced to 2; render static accessible fallback.

API Reference

Syntax

AdaptiveQuality exposes the fused quality tier, hardware diagnostics, and decision cause.

Parameters

Parameters.fieldTypeDefaultDescription
getAdaptiveQuality()AdaptiveQualitySingletonReturns the global shared instance. Safe to call during server-side rendering.
quality.subscribe(fn)(fn: (state: AdaptiveState) => void) => () => voidSubscriptionSubscribes to fused tier changes. Fires immediately with current state. Returns cleanup function.
useAdaptiveQuality()() => AdaptiveStateReact HookReact hook that subscribes to quality changes and returns the current AdaptiveState snapshot.

Return Value

AdaptiveState

State snapshot containing effective tier, deviceTier, budgetTier, cause, reasons, and reducedMotion.

Properties & State

Properties.fieldTypeDescription
quality.stateAdaptiveStateThe live snapshot containing the effective tier and hardware diagnostic metadata.

AdaptiveState

AdaptiveState.fieldTypeDescription
tier0 | 1 | 2The effective quality tier to consume in UI and renderers (0 = high, 1 = medium, 2 = low).
label"high" | "medium" | "low"The effective tier verdict as a string.
deviceTier0 | 1 | 2Static hardware floor from initial probe. Never lifts at runtime.
budgetTier0 | 1 | 2Live tier from AnimationBudget based on presented frame intervals.
cause"ok" | "device" | "reduced-motion" | "render" | "frame-rate" | "held"Machine-readable reason for the effective tier verdict.
reasonsstring[]Human-readable explanation array from device probe (e.g. ["mobile-class GPU", "constrained memory/cores"]).
reducedMotionbooleanWhether prefers-reduced-motion media query was matched during probe.

Subscription Cleanup

Subscriptions to AdaptiveQuality should be cleaned up on component unmount.

1. Vanilla JS UsageManual Subscribe / Unsubscribe
2. React Hook UsageAutomatic Cleanup

Lifecycle & Invariant Guarantees

  • Immovable hardware floor: A low-end mobile phone or software renderer will never be promoted to tier 0, eliminating quality oscillation.
  • Zero external dependencies: Hardware heuristics use zero external GPU databases or remote network lookups, executing synchronously and locally in <1ms.
  • Attribution-aware shedding: When third-party ad scripts block the main thread, the governor flags the cause as 'held' rather than unnecessarily punishing visual quality.
  • Safe SSR defaults: During server-side rendering, probes safely default to tier 0 to ensure server output and first client hydration match without layout shift.

Hardware Inspection Telemetry

Real-time hardware capability probe executed on client initialization. Heuristics classify the device into an immovable baseline floor.

WebGL2
unknown
cores
unknown
memory
HIGH (0)
device tier
GPU Unmasked Renderer
unavailable

Production Examples

Battle-tested production patterns ready to copy directly into your codebase.

Map the tier to a settings object once, then feed it to the canvas backing store and particle pool.

When NOT to use this

The scene is already mounted and you only care about live frame drops.
→ instead Use AnimationBudget: you do not need the static device floor to drop an optional particle layer on a running page.
Deciding whether to mount an expensive 3D component at all.
→ instead Use useSafeToMount, which gates on measured frame headroom before paying mount and shader compilation costs.
Requiring exact benchmark scores or GPU model databases.
→ instead Feature-detect the specific WebGL extension or capability you require. AdaptiveQuality provides conservative heuristics without external databases.
Differentiating a capable GPU from a user requesting reduced motion.
→ instead Inspect cause and reducedMotion: when prefers-reduced-motion is active, tier is forced to 2 and cause reads 'reduced-motion'.

Rules & Gotchas

  • Always consume the effective tier: deviceTier and budgetTier explain the verdict in telemetry; tier is the single fused value you render from.
  • The hardware floor never lifts: Clean frames do not promote a software-renderer or mobile envelope device to tier 0. The floor remains stable.
  • Map tier to a centralized settings object: Scattering raw tier === 0 checks across render passes makes testing difficult. Use a single dictionary map.
  • Never remount canvases on tier transitions: Mutate the live renderer in place. Re-keying a canvas re-allocates WebGL contexts and introduces severe startup stutter.

Related Motion Components