Docs / Guides
Performance
OpenFini targets low-power hardware: old laptops, ARM single-board computers, budget tablets. This page explains how that is achieved and records measurements you can reproduce.
Design rules#
- Do less. Nothing renders unless something changed (
requestAnimationFramecoalescing, no idle loop). Display lists are cached per node and reused across zooming and panning. - Never block on a gesture. Panning and zooming move the already-rendered bitmaps with a GPU-composited CSS transform and re-render once when the gesture settles (70 ms, or 140 ms when frames were slow). Scrolling costs no JavaScript.
- Touch only what changed. Brush strokes recomposite the 256×256 tiles they touched; undo stores the dirty rectangle, not the layer; retouching works on small patches around each dab.
- No mandatory GPU features. Canvas 2D only — no WebGL, no WebGPU, no OffscreenCanvas requirement.
Effects use the browser's native shadow engine and
ctx.filterwhen available, with a pure-JS fallback. - Lazy everything. UI components, panels and effect parameter forms are created on first use. Shoelace components load on demand. Algorithms live in small modules.
- Bounded memory. History is capped by bytes (96 MB, 32 MB in low-power mode), temporary canvases are pooled, sprite caches are size-limited.
- Small download. No framework; production JavaScript is minified; assets are precached for offline use.
Low-power mode#
Preferences ▸ Low-power mode (Auto by default: enabled when the device reports ≤ 4 CPU cores or ≤ 4 GB RAM):
| Normal | Low-power | |
|---|---|---|
| Canvas resolution cap | 2× device pixels | 1× |
| Page shadows | on | off |
| Undo memory | 96 MB | 32 MB |
| Live layer effects (shadows, glows, blur) while dragging | full quality | skipped until release |
Measurements#
Measured on a Windows 11 ARM64 laptop with a Chromium-based WebView, development build for the workload tests and production build for start-up. Your numbers will differ; re-run the scripts below.
Start-up (production build, cold, no session to restore)#
| Metric | Result |
|---|---|
| DOMContentLoaded | 83 ms |
| First contentful paint | 208 ms |
| JavaScript heap after start | 6.1 MB |
| JavaScript requested during start-up | 73 files, 832 KB uncompressed (Shoelace components included) |
| Application JavaScript (gzip, all chunks incl. the lazily loaded studios, engines and the Vibe Studio AI runtime) | 839 KiB (budget 900 KiB) |
| JavaScript needed to start (gzip, static import closure) | 317 KiB (budget 340 KiB) |
| PDF import (pdf.js and wasm, gzip, loaded when you open a PDF) | about 610 KiB, not precached |
| Total download incl. all lazily loaded Shoelace files (gzip, no fonts) | 701 KiB (budget 2 MiB) |
Code studio (production build, local server, cold)#
| Metric | Result |
|---|---|
| Start-up cost when the studio is not used | none (editor, engine and panels are lazy chunks) |
| Create a website from a template → live preview on screen | ~260 ms |
| Lazily loaded on first use | CodeMirror bundle 628 KB (216 KiB gzip), studio and engine chunks ~300 KB |
| JavaScript heap | 22 MB → 29 MB with the studio open |
| Stylesheet edit → canvas updated (no reload) | ~90 ms |
| Parsing 1 MB of HTML / CSS | ~25 ms each (Node) |
Rendering and editing#
| Workload | Result |
|---|---|
| 1,500 shapes (rectangles, ellipses, stars, 25 % gradients), cold render of the viewport | 32 ms |
| Same, warm re-render | 5 ms |
| Same, after panning | 4 ms |
| Plus 20 live drop shadows | 14 ms |
| 12-megapixel pixel layer (4000×3000), viewport render | 19 ms |
| 12 MP + one HSL adjustment layer (1.2 MP viewport, warm) | 31 ms |
| 12 MP + HSL + live Gaussian blur, full quality | 133 ms |
| Same while dragging or painting (half-resolution draft) | 45 ms |
| Brush stroke, 400 pointer events, 120 px brush, 12 MP layer | 151 ms total |
| JavaScript heap with the 12 MP document open | 88 MB |
Pixel engine (Node 24, 2-megapixel image)#
| Operation | Time |
|---|---|
| Gaussian blur (opaque / translucent) | ~110 ms / ~165 ms |
| Levels / Curves | ~8 ms |
| Resize 50 % (bicubic / Lanczos-3) | ~79 ms / ~93 ms |
| Develop pipeline (exposure, shadows / highlights, contrast, clarity, vibrance) | ~180 ms |
| Selection contour tracing, 4000² disc | ~100 ms |
Reproduce with node tests/pixel/bench.mjs.
Worker pool#
app/src/core/workers/ runs heavy pure jobs off the UI thread (runJob(name, args, { transfer, signal, onProgress });
lazy, hardwareConcurrency - 1 workers capped at 4, cancellation terminates the worker, same code runs locally when
Workers are unavailable). Jobs were picked by measurement (Node 24, synthetic data):
| Job | Blocked the UI thread for | Now |
|---|---|---|
pixel.resize: Resize Document with Lanczos, 4000×3000 → 2000×1500, per layer | ~480 ms | worker; layers in parallel. In Chromium the whole command took 0.7 s with the longest main-thread gap 115 ms (getImageData/putImageData) |
pixel.trace: Trace Image (scale-down to 900 px + trace) | ~225 ms + resize | worker; longest gap 52 ms |
zip.compress: save with an 11 MB document.json | ~250 ms | worker when more than 512 KB are deflated |
Left on the main thread: unzip on open (~35 ms for the same file), RAG indexing (~70 ms for 2 MB of text) and live
filter layers (they need an asynchronous render pipeline first). Add a job to jobs.js only with a measurement.
Jobs read image bytes through jobs.js ▸ asImage, which accepts any byte view, an ArrayBuffer or a plain array and
throws when the data is shorter than width × height × 4 instead of analysing a short buffer.
Scene Studio memory#
The media store (scene/media.js) holds one object URL per media item (a full copy of the file), decoded images,
one frame-reader <video> per item, decoded sound and waveform peaks. The viewer's prune pass (every 5 s while idle)
releases all of that for items that left the bin, not only on closing the document, so importing and removing
footage in a long session no longer accumulates copies. A media probe that fails or times out also releases its
element. Undo brings an item back and it loads again on demand.
Known limits#
- Adjustment and filter layers are computed in JavaScript on the viewport pixels. Simple adjustments cost tens of milliseconds per frame, heavy filters (blur, median, defocus) and large windows cost more. While you drag or paint, effects are computed at half resolution (a quick draft) and the full-quality frame follows when you release; panning and zooming use the CSS preview. A stack of several heavy live filters on a slow CPU can still make painting beneath it feel slow — hide them while painting. Moving these effects to a Web Worker / WebAssembly is on the roadmap.
- Very large documents (> 50 MP per layer) are limited by the WebView's canvas memory; the export size is capped at 16,384 px per side and 140 MP.
- Median, defocus and oil-paint filters are CPU heavy at large radii.
Budgets in CI#
npm run check:size fails the build when a gzip size exceeds its budget in
scripts/size-budget.json: all application JavaScript (shellJsGzipKiB), the JavaScript
needed to start (startupJsGzipKiB) and the total download without fonts and on-demand libraries (totalGzipKiB). The
file's $comment records why each budget changed.
Budget history of the start-up JavaScript: 340 KiB (0.3) → raised feature by feature to 380 KiB (0.8) → lowered to 365 KiB after refactoring audit 1 (measured 357.2 KiB + 2 %; the export dialog and the text-tool transforms left start-up). Details and the list of further candidates: refactoring-audit.md.
Edit on GitHub → docs/performance.md