CrymbleUI apps now run in the browser (WebAssembly)

Following up on News on CrymbleUI and Embrace from 2.6.2026:

Any CrymbleUI app now also builds, unchanged, as a static web page - the same Crystal compiled to WebAssembly, drawing on an HTML canvas. No server, nothing to install, it runs in the browser tab only.

Try it (desktop browser with mouse and keyboard; tested in Chromium and Firefox):

  • CrymbleUI showcase - widgets, scrolling, layers, drag and drop
  • Minesweeper - a small app with CrymbleUI as a plain shard dependency (source) - the one to copy for your own app
  • H3O Embrace - the full desktop data application, ~14k LOC, built from the same source as its Linux and Windows binaries

How it works:

  • no {% if flag?(:wasm32) %} in the app - the flavour is a property of the build: a second CrymbleUI backend paints the same pixels as the SFML one (checked against the desktop by a conformance suite)
  • shards install puts bin/crymble-web into your app; then
    bin/crymble-web setup     # once: the toolchain (a few minutes, ~1 GB)
    bin/crymble-web build     # bin/web/<target>/ - copy it to any static web server
    bin/crymble-web serve     # try it locally
    
  • toolchain: Crystal 1.22.0 + a small compiler patch, wasi-sdk 25, Boehm GC 8.2.8, Binaryen - all pinned and built reproducibly by setup
  • the patch (in tools/wasm/, every change explained in its header): wasm exceptions (stock 1.22 exits on raise), struct returns from C, Boehm as the wasm32 collector (stock: no collection at all), and a few WASI file-system fixes - maybe of interest upstream?

Limits as of now: Safari not tried yet; the browser keeps some shortcuts for itself (Ctrl+W/N/T/Tab); files saved live in the tab only.

Versions: CrymbleUI v1.9.4 (src ~42k LOC, spec ~88k LOC - still fully AI generated), Embrace v2.6.1.

Feedback welcome - especially how it behaves in Safari and on a Mac!

Loved the Minesweeper :slightly_smiling_face:

Yesterday’s web assembly builds were still without --release, since this broke both crystal compiler and LLVM - and have been a tad slow. Even so my embrace wasm was broken on some simple use cases.

With the new locally added compiler patches all works, including --release. All binaries updated - and now faster and more compact.

See also Don't precompute `sizeof` and `offsetof` of types holding a module or an abstract struct by jochenseeber · Pull Request #17609 · crystal-lang/crystal · GitHub