What vapors reuses between frames, and how it is measured.
vapors combines HTML and SVG elements with its own 3D elements in component templates, with component-scoped CSS for styling. Templates compile into Rust, and rendering runs on the GPU. It retains style, layout and drawing data between updates and shares computed styles. The compiler already translates templates and validates component CSS. The aim is to move as much work as possible to build time, leaving runtime work for values and conditions that depend on the running app.
Native desktop, Android, iOS and WebAssembly are primary delivery targets. On mobile, the performance goals include responsive touch input, low memory use and avoiding unnecessary rendering and battery consumption. Desktop and browser demos run today; native mobile delivery is planned. Platform direction and status.
How this differs from browser HTML and CSS
In a web page, HTML creates DOM elements and the browser applies CSS, lays out those elements and renders them. In vapors, component templates compile into Rust code that creates elements in vapors' own UI tree. vapors handles their styling, layout and rendering. In a browser, the app runs as WebAssembly and renders into a GPU-backed canvas; its interface elements are not browser DOM elements.
The template language and CSS support are deliberately constrained. Component-scoped styles, literal class and style attributes, and explicit conditional classes give the compiler information it can check and prepare. This is a subset of browser HTML and CSS, with its own rules; existing web pages cannot be used unchanged. The styling reference describes what is supported.
Browsers also cache rendering data and optimise scrolling. For example, Chromium retains display lists and GPU textures. Reusing work is not unique to vapors. Its architectural difference is compiling component templates for its own runtime and renderer, with scope to prepare more work during compilation. Stylesheets are still parsed at run time, and rules that depend on state are matched at run time. These differences alone do not establish a speed advantage over a browser.
Changing an element
To show an interface, vapors works out each element's style, size and position, then prepares its drawing data. It keeps those results between updates. A change marks the affected elements, including elements whose layout or style depends on them, so unchanged results can be reused. There is no virtual DOM comparison to discover what changed. Text, attribute and child-list edits mark the affected elements directly. Retained layout boxes keep their identities and caches when their inputs have not changed.
In the long-list benchmark, changing a row's text without changing its size updates that row without recalculating the other rows. A change that makes the row taller also repositions the rows below it. The amount of work depends on what the change affects.
items holds the list's reactive state. When that state
changes, vapors updates the interface automatically. Each item's key
lets vapors preserve its component across updates:
<ul> {for item in items.get() key=item.0} <TodoItem label={item.get().1} /> {/for}</ul> Inserting or removing a row in a list of 32 or more rows whose positions are whole device pixels does not reposition the rows after it: each row is placed relative to the list, and the rows after it move by one offset. Rows at fractional device-pixel positions, rows holding a scroll container, and lists with absolutely or fixed positioned children still reposition every later row.
Scrolling
vapors keeps drawing data in GPU buffers between frames. Each scrollable area has its own coordinates, and scrolling changes an offset that the GPU applies when drawing that area. Unchanged drawing data can be reused; entries coming into view need to be added to the visible batches.
Reuse happens at three levels: drawing records for individual layout boxes, batches of visible drawing entries, and the GPU buffers holding those batches. A batch groups entries that can be drawn together.
The GPU still draws the visible content for the new frame. Reusing the buffers avoids rebuilding and uploading unchanged data. A position index finds visible entries without walking every off-screen row.
Leaving an app idle
An unchanged interface does not need a continuous redraw loop. vapors requests a frame when the document changes. Timers, animation and other application activity can wake it again.
The idle test checks that an unchanged page requests no frames and does no update work. It runs without a display; it does not yet cover every platform wake-up, such as timers or GPU readbacks.
Opening a large interface
Opening a list still creates and lays out every mounted row. Retaining results reduces later update work; it does not remove that initial cost or the memory needed to keep the rows. On a page of 10,000 rows, the first frame took 909 ms with a warm shader cache and 1,027 ms cold, and layout was 606 ms of the 833 ms start-up (warm), measured as listed under Recorded measurements.
Elements with the same template key and style inputs share a computed style. Repeated rows can therefore reuse style records. Different parent styles, hover or focus states, and toggled classes can require additional records. Selector-dependent attributes also affect reuse; container queries can prevent sharing when their answer depends on an ancestor's size. Style sharing does not remove per-element layout and drawing data.
Low-level optimisations already in place
- Indexed element storage. Element records live in arrays. Common fields stay in each record; uncommon data, such as outlines and scrollbar thumbs, is allocated separately where needed. This keeps the common records smaller and reduces the data read when traversing them.
- Shared computed styles. Matching template keys and style inputs reuse one computed style, reducing duplicate style calculations and storage.
- Retained layout and drawing data. Updates reuse unaffected results instead of recalculating them. The benefit depends on which elements a change affects.
- Changed GPU batches only. Unchanged batches keep their GPU buffers. Uploads are limited to batches whose contents changed, reducing data transferred for an update.
- Indexes for visible content. A position index finds drawing entries in the viewport without scanning every row. Drawing steps and index entries are stored in blocks, so an insertion need not shift the entire array. This does not remove the layout work of repositioning later rows.
What Rust contributes
Apps compile to native code on desktop and WebAssembly in the browser. Rust manages its allocations through ownership rather than a tracing garbage collector. This avoids collection pauses for those allocations; it does not eliminate other sources of delay in an app or its browser host.
vapors also compiles component templates into Rust, so they need no template interpreter at run time. Compiled templates, retained drawing data and indexed element storage are choices made by vapors, rather than properties of every Rust GUI framework.
What the compiler checks and prepares
- CSS validation. The compiler checks each component's style block using the rendering engine's CSS implementation. Unsupported properties, units and selectors stop the build with a file, line and column.
- Known classes.
classandstyletake literal values. Conditional classes useclass:name={bool}, so the compiler can see each class an element may have. - Style keys. The compiler assigns template keys that the runtime uses, together with style inputs, to share computed styles.
- Rules that always apply. For each template element,
the compiler sorts the component's rules into those that always match
it, those that never do and those that depend on state such as
:hoveror a conditional class. At run time only the state-dependent rules, and rules from other crates' stylesheets, are matched, once per style key. Every build checks the first element of each key against the full cascade and refuses the key if they differ.
Stylesheets are still parsed when a component first mounts. CSS validation and errors.
Recorded measurements
Each result names the build and workload it was measured on. A measured build can be older than the framework revision the rest of this site describes.
| Measurement | Result | Scope |
|---|---|---|
| Hosted Wasm binary | 9.73 MiB raw; 4.75 MiB with gzip level 9 | Release bundle at 40f410f,
including the component demos, the image viewer, the one-scene example and the racer. Excludes
JavaScript and page assets. Compressed size does not establish
the server's transfer encoding. |
| Racer frame time | No frame over 16.7 ms in 12 runs: six at 1 sample per pixel, six at 4. Median frame, from the start of its update to the GPU finishing: 7.5 ms at 1 sample, 9.5 ms at 4. | Release d397448, with the racer's world drawn by the
scene renderer; Intel UHD 630, Mesa ANV, Vulkan; offscreen
rendering at 1100 × 720 with no present. Each run is 3,750 frames
of a scripted drive, every frame judged from the first; three
pairs per sample count, each a cold shader cache then a warm one.
Startup before the first frame and display presentation are not
measured. |
| First frame of a large page | 909 ms warm, 1,027 ms cold at 10,000 rows; 98 ms warm and 208 ms cold at 1,000 rows | Release 160b966, Intel UHD 630, Mesa ANV, Vulkan,
640 × 400. From mount to the GPU finishing frame 0; a page of rows
of two spans and a button; median of three runs per cache
state, cold being an empty shader cache. |
| Heap allocation per element | 34,736 → 11,384 bytes | At 16,384 rows (65,538 elements), before and after the layout
and paint storage changes recorded from 7c4fc70; the
same page of rows. Requested live heap bytes after mount and
settle, one page per process; excludes allocator overhead, peak
usage and GPU memory. |
Sources and reproduction commands: hosted build provenance, racer measurements, first-frame measurements, memory measurements. These are not comparisons with another framework or guarantees for other devices.
How these choices are tested
The vapors-perf harness applies changes to real pages and
measures how update work grows with the number of rows. Separate checks
measure frame time, GPU time and memory, and compare retained results
with a full recomputation to catch incorrect reuse.
Measurements and correctness checks
- Work per change. CPU instruction counters measure
style, layout, paint and draw work at several list sizes. Scaling
checks identify operations whose cost grows with the page.
--countersadds each phase's cycles, instructions per cycle, branch misses and cache misses. Nightly runs on main report regressions as issues. - Frame time. Repeated timed runs measure update and draw duration; runs on a busy machine are refused. Timing captures costs that instruction counts alone cannot explain. GPU timestamp queries measure work on the GPU separately.
- Memory. A counting allocator measures live heap allocations after mounting pages of different sizes, including per-element storage and shared styles.
- Sustained interaction. A long-run check drives a scene through its input and checks each frame against a frame-time budget, with cold and warm shader caches. This tests the selected scene and machine, not a frame-rate guarantee for every device.
- Correctness. Debug checks compare retained layout, drawing data and GPU uploads with freshly computed results, stopping at the first difference and naming it.
Still in progress
- Structural list updates. The cases above that still reposition every later row.
- Clips as data. Rectangular clips are being moved from GPU state into a table the shaders read, so drawing can be batched across clipped regions. Rounded clips are not done.
- HTML, SVG and 3D composition. They appear in the same frame today, with 3D rendered into its own texture. Next: the scene drawn in the painter's pass, then SVG shapes on 3D objects, then a 60-second scripted run of the result judged frame by frame.
Further reading
- HTML, SVG and 3D in one frame: what one component can draw today and what is coming soon.