Skip to content

SIMUT v2.2.11-beta — "Connection lost", with the device on the LAN

Choose a tag to compare

@angeloINTJ angeloINTJ released this 19 Aug 00:30
· 846 commits to main since this release

"Connection lost", with the device on the LAN

The history page loaded Chart.js from cdn.jsdelivr.net. With no internet the new Chart(...) call threw a ReferenceError, the loader’s catch swallowed it, and the user read Connection lost. — while the device was on the local network and the .h5 had already been downloaded and decoded. The failure blamed the network for a missing script, in a product whose first promise is offline-first.

The same tag carried two more defects. It pinned no version — npm/chart.js resolves to whatever major jsDelivr publishes, and v3→v4 already broke the options API once, so a future release would stop the graph on devices already in the field. And it had no integrity, in a document that holds the session cookie, served without a CSP.

Trimming the library was measured, and does not solve it

Registering only what the page uses takes Chart.js 4.5.1 from 70 592 to 56 818 B gzipped — twenty percent, because the weight is not in the chart types nobody uses:

core alone, nothing registered ..... 43 527 B   draws zero pixels
+ LinearScale ...................... 43 534 B   +7
+ Line/Point ....................... 49 049 B   +5 515
+ Legend + Tooltip ................. 56 818 B   +7 769
+ everything else .................. 70 719 B   +13 901

Adding the linear scale costs seven bytes, because the scale engine is already in the core. What is irreducible is generality: the Proxy-based option cascade, the animation engine shipped even with animation: false, six interaction modes, a full CSS colour parser, spline maths.

h5g

A renderer that already knows it has three axes, one series type and fixed tick steps: 784 lines, 4 721 B gzipped, 15× smaller than the CDN bundle. Three independent Y axes, line broken on null, per-quantity dash, visible radius on isolated samples, min/max band, clickable legend, nearest-x tooltip, resize, DPR and touch.

Two behaviours were changed deliberately rather than copied:

  • The band is inside the Y range. Its peak used to be clipped by the edge of the plot, and in a cold chain that peak is the excursion. The MAX/MIN badges give the number, but only with a single sensor selected — with two or more the extreme disappeared entirely.
  • X labels rotate 45° when they no longer fit, instead of thinning the ticks. Thinning cost the grid along with the labels: at 375 px the axis went from seven vertical lines to three.

Proved against the engine it replaces

Eight frozen cases and seven interaction captures rendered through the page’s own renderChart, extracted from WebUI.h rather than copied. The first gate was the control: two runs of the same Chart.js requiring zero differing pixels.

Every X axis matches Chart.js exactly. Thirty chart swaps leave listeners at 5 → 5 — the leak detector was itself verified by removing destroy()’s unbind, which takes the count to 93. On hardware, delivered by two OTA hops through the v2.2.10-beta applier: a browser pointed at the device with external DNS disabled made 33 requests, none external, no JS errors, and drew the graph.

Flash

release headroom ... 44 044 B -> 38 604 B

5 440 bytes, in exchange for removing a 70 592 B external download from every visit to the page.


Full notes: CHANGELOG.md · Português