Repository navigation
SnapDOM v3 is comming!!! #481
Replies: 1 comment
Where v3 stands against v2 — Sept 2A plain summary of what changed, all of it measured against the 2.24 you are running today. The first capture of an element is about twice as fast. v2 read around 400 computed properties per node; v3 scans the page's stylesheets once, learns which properties the CSS can actually touch, and reads only those, usually around 50. A complex node at 1200×800 goes from 4.1 ms to 2.6, and at 4000×2000 from 34 to 21. Repeat captures are close to free. Capture the same element three times inside two seconds and v3 starts memoizing on its own. An unchanged repeat returns from memory, and when something does change, only the mutated subtree is rebuilt, with output byte-identical to a full capture. Twenty captures of an unchanged element cost 8.2 ms in v2 and 1.5 in v3. Nothing to configure and no API to learn; the old Pictures cost less. Inlined images are downsampled to the resolution the output can show, in a worker pool, and the fetched bytes are handed to the worker directly instead of as a base64 string. A nine-photo gallery exported to PNG at 2× went from 510 ms to 146. Pseudo-elements were the expensive thing nobody had measured. Each inlined Web fonts embed by themselves. The SVG a capture rasterizes from cannot see the page's loaded fonts, so v2 silently rendered webfont text in a fallback face unless you opted in. v3 detects webfont usage and embeds exactly what the capture needs; a system-font page pays nothing. Safari was rewritten rather than patched. The hidden triple warm-up before every capture is gone, replaced by a draw that waits exactly as long as WebKit needs. The bug where the first capture of an element with a nested image came back fully transparent, which had survived five earlier attempts, is fixed and was verified in real Safari 26.5 with a hundred consecutive captures, every one byte-identical. And A few things v2 renders wrong are right in v3. An image with padding or a border no longer comes out scaled inside a box that is too large. Per-capture state is isolated. v2 kept a mutable session at module level, which is where a whole family of cross-capture races lived. In v3 that state travels with the capture, so those bugs cannot be written anymore. The tests got a new kind of check. Visual baselines are recorded by SnapDOM itself, so a systematic mistake becomes the baseline and passes forever; that is exactly how a v3-only grid bug hid until I screenshotted the live element. There is now a test that compares captures against a real screenshot of the DOM, and it catches that class of error with a wide margin. The suite is 4,017 tests, green on Chromium, Firefox and WebKit. Two things break on purpose and are listed in the README under Migrating from v2: |
Uh oh!
There was an error while loading. Please reload this page.
Short version: v3 is an engine rework. Most of what you use day to day already shipped in 2.24. What changes underneath is how fast a capture is, and how it behaves when you call it more than once.
Faster first capture
The engine now scans your stylesheets once to learn which CSS properties your page can actually use. Every node then snapshots around 50 properties instead of 400. That read was the biggest cost in any DOM capture.
Repeat captures get much cheaper
v2 had memoization, but you had to turn it on. In v3 it engages on its own: capture the same element a few times and unchanged repeats return instantly. When something does change, only the changed subtrees are rebuilt, and the result is byte identical to a full capture. Nothing to configure.
Web fonts embed by default
In v2 you had to opt in, and if you did not, webfont text quietly rendered with fallback metrics. v3 detects it and embeds only what the capture needs. Pages that use system fonts pay nothing.
Fewer knobs
fastis gone,cacheis now a single debug switch, and per capture state is isolated so concurrent captures cannot interfere with each other.Status
v3 is in beta and not published yet. The current release stays 2.24.x. I will post again when the beta is on npm.
All reactions