Skip to content

ariglx-web: a Pillow case in the browser smoke, once the zip has PIL - #1201

Merged
transfix merged 7 commits into
masterfrom
feat/ox-wasm-pillow
Nov 14, 2026
Merged

transfix merged 7 commits into
masterfrom
feat/ox-wasm-pillow

Conversation

@transfix

Copy link
Copy Markdown
Owner

W5, first part (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md §10 Phases; pillow is first in §5.2's C-extension order, built to §5.5's convention): a Pillow case in ariglx-web's browser smoke. cvcpkg's pillow-cp312 for wasm and wasm-mt is cy-pca/cvcpkg#613 (unpublished). In that package each PIL extension is one relocatable object with its codecs linked in and localized, and the objects are listed in share/python-wasm/pillow-cp312.inittab. ariglx-web links it with no change: ariadne_python.cmake globs that directory, and make_python_zip.py already zips PIL's .py files.

What it adds

  • src/arigl/web/test/python/pillow.ari (requires python, python.numpy, python.PIL) checks the pinned codecs and round-trips an image through PNG, JPEG, TIFF (deflate) and lossless WebP. It also draws text with ImageFont.load_default() through FreeType and hands the image to numpy.
  • arigl_web_smoke.mjs runs the case when python312.zip has PIL/__init__.py, as the vtk case is gated on vtkmodules. With --expect-pil (which needs --pydocs) it runs whatever the zip holds, so a zip that lost PIL fails on the import.
  • ci.yml's ariglx-web job passes --expect-pil when $WASM_DEPS has share/python-wasm/pillow-cp312.inittab, the manifest the configure links PIL from. Once the follow-up adds pillow-cp312 to the recipe's depends.build, the case is required with no smoke or CI change.
  • The roadmap's W5 row and docs/CVCGL_WASM.md say what is built and what isn't.

A green ariglx-web check doesn't cover the Pillow case. This PR touches src/arigl, so the 240-minute job runs, but its deps have no pillow-cp312. pillow-cp312 isn't in the recipe and isn't published for wasm, so the job passes no flag and runs master's 9 cases. The evidence for the Pillow case is the local run below.

How it was tested (sandipaws, Windows 11)

ariglx-web lean tier built on Windows against a private wasm deps prefix (python312 3.12.10+cvc.25, numpy-cp312 cvc.6) with the packed pillow-cp312 wasm bundle from cy-pca/cvcpkg#613 overlaid; the configure linked 19 extension objects (numpy's 14, PIL's 5). arigl_web_smoke.mjs --pydocs in headless Chrome:

  • the staged PIL build (ariglx.wasm 99,183,379 bytes) with --expect-pil: all 10 passed, including ariglx-web: PIL 12.3.0 features zlib,jpg,libtiff,freetype2,webp, round-trips PNG,JPEG,TIFF,WEBP, array (8, 8, 3) (pass);
  • the same wasm, a zip without PIL, --expect-pil: the Pillow case failed with ModuleNotFoundError: No module named 'PIL', 1 of 10 failed, exit 1 (expected; pass);
  • the same zip, no flag: the case was skipped, all 9 passed (pass);
  • --expect-pil without --pydocs: usage error, exit 2 (pass);
  • in the first round, PIL in the zip but its manifest not linked: the Pillow case failed (ImportError for PIL._imaging), the rest passed.

ci.yml parses with PyYAML, and the step's flag logic gives --expect-pil only when the prefix has pillow-cp312.inittab (pass).

The cvcpkg side was tested on its own PR: the new test_pillow_wasm_features.py (10 passed), the recipe and wasm_pyext suites (210 passed, 4 skipped, 0 failed), cvcpkg validate, and WSL builds and packs of both flavors with their gates, node probes and negative controls.

What PIL adds to the lean tier (wasm-opt -O3): ariglx.wasm grows from 95,579,004 to 99,183,379 bytes (+3.4 MiB raw, +1.18 MB gzip -9, +0.68 MB brotli -q 11). python312.zip grows from 14,235,066 to 15,427,780 bytes (+0.23 MB brotli).

No C or C++ changed, so the clang-format check has nothing to read.

Left out

  • ariglx-web's depends.build. The other option was to hold this until pillow-cp312 is published for wasm and add - name: pillow-cp312 to ariglx-web's depends.build here, so CI runs the case. That is Joe's call. This PR takes the documented route: it lands the case dormant, and this body says the green check doesn't cover it. Adding the line after pillow-cp312: wasm and wasm-mt, one namespace per extension (cvc.2) cy-pca/cvcpkg#613 is reviewed and populated is a one-line follow-up.
  • libwebp's plain wasm column. The plain-wasm libwebp archives were built with threads (+atomics on every member), so plain _imaging and _webp reference pthread_*. Building it with WEBP_USE_THREAD=OFF belongs in a separate libwebp recipe PR in cvcpkg.
  • The first commit's message still names the cvcpkg branch (feat/pillow-wasm); the last commit points the W5 row at pillow-cp312: wasm and wasm-mt, one namespace per extension (cvc.2) cy-pca/cvcpkg#613.

Merging waits on Joe's review.

#1159 (O7c) kept the last source sea_surface found in a thread_local, so
the velocity a fluid field reads after a cell's height at the same point
and time did not invert the sideways move again. A thread_local that
keeps state between calls is a static cache, which libcvc's no-singletons
rule forbids (VOLROVER-LIBRARY-PORTS-ROADMAP.md 1.3,
tools/singleton_scan). #1159's release-grpc job, where the scan runs, was
cancelled, so the scan never judged it; the next PR that merges master
would fail that lane on it.

The memo now belongs to the caller:

- sea_surface::source_memo, and height() / velocity() overloads that take
  one. The plain reads share nothing.
- fluid_surface::height_with / velocity_with and a surface_memo the
  caller owns; the defaults ignore it. ocean_surface passes it to the sea.
- field_set::apply keeps one memo per cell, for the cell's height and its
  velocity at the same clipped centre.

The memo is keyed on the point, the time and the digest as before, so
every value is unchanged.
W5's first part is cvcpkg's pillow-cp312 for wasm and wasm-mt (cy-pca/cvcpkg
feat/pillow-wasm, cvc.2, unpublished): each PIL extension is one relocatable
object with its codec libraries linked in and localized, listed in
share/python-wasm/pillow-cp312.inittab. ariglx-web needs no change to link
it: ariadne_python.cmake globs that directory and make_python_zip.py
already zips PIL's .py files.

src/arigl/web/test/python/pillow.ari (requires python, python.numpy,
python.PIL) checks the codecs the package pins, round-trips an image
through PNG, JPEG, TIFF (deflate) and lossless WebP, draws text with
ImageFont.load_default() through FreeType, and hands the image to numpy.
arigl_web_smoke.mjs runs it only when python312.zip holds PIL/__init__.py,
as the vtk case is gated on vtkmodules. CI's ariglx-web job installs the
recipe's deps, which don't list pillow-cp312 yet, so the case stays
dormant there until the bundle is published and the recipe depends on it
(a one-line follow-up). The roadmap's W5 row and CVCGL_WASM.md say so.

What PIL costs the lean tier (this build, wasm-opt -O3): ariglx.wasm
95,579,004 -> 99,183,379 bytes (+3.4 MiB raw, +1.18 MB gzip -9, +0.68 MB
brotli -q 11), python312.zip 14,235,066 -> 15,427,780 (+1.19 MB stored,
+0.23 MB brotli).

Tests: ariglx-web lean built on Windows against a private wasm deps
prefix (python312 3.12.10+cvc.25, numpy-cp312 cvc.6) with the packed
pillow-cp312 wasm bundle overlaid: the configure linked 19 extension
objects (numpy's 14, PIL's 5), and arigl_web_smoke.mjs --pydocs in
headless Chrome passed all 10 cases, the Pillow one included. With a
python312.zip built without PIL it skipped the Pillow case and passed
the other 9. Relinked without PIL's manifest but with PIL in the zip, the
Pillow case failed (ImportError for PIL._imaging) and the rest passed.
arigl_web_smoke.mjs skipped the Pillow case whenever python312.zip had no
PIL/__init__.py. Once the ariglx-web recipe depends on pillow-cp312, a zip
that lost PIL (make_python_zip.py has --exclude, and nothing checks that a
linked inittab package's .py files are in the zip) would then still pass,
with PIL's extensions linked in and nothing importing them.

--expect-pil (with --pydocs) runs the case whatever the zip holds, so a zip
without PIL fails it on the import. ci.yml's ariglx-web job passes the flag
when $WASM_DEPS has share/python-wasm/pillow-cp312.inittab, the manifest
the configure links PIL from. The follow-up that adds pillow-cp312 to the
recipe's depends.build then needs no smoke or CI change for the case to be
required.

Until then CI's deps have no pillow-cp312 (it isn't published for wasm
yet), so the job passes no flag and runs master's 9 cases: a green
ariglx-web check says nothing about PIL in the page. The evidence for the
Pillow case is the local smoke in headless Chrome below.

The roadmap's W5 row and CVCGL_WASM.md say so.

Tests: arigl_web_smoke.mjs --pydocs on the lean tier built on Windows
with the packed pillow-cp312 wasm bundle overlaid (ariglx.wasm
99,183,379 bytes, PIL's 5 extensions linked in):
- --expect-pil, PIL in the zip: all 10 passed, the PIL report line
  included;
- --expect-pil, the same wasm with a zip built without PIL: the Pillow
  case failed (ModuleNotFoundError: No module named 'PIL'), 1 of 10
  failed, exit 1;
- no flag, that zip: the case skipped, all 9 passed;
- --expect-pil without --pydocs: usage, exit 2.
ci.yml still parses (PyYAML), and the step's flag logic gives
--expect-pil for a prefix with the manifest and nothing for one without.
The W5 row named the cvcpkg branch (feat/pillow-wasm) because the
cvcpkg PR didn't exist yet. It is cy-pca/cvcpkg#613.
@transfix
transfix enabled auto-merge (squash) November 13, 2026 03:54
transfix added a commit to cy-pca/cvcpkg that referenced this pull request Nov 14, 2026
…613)

pillow-cp312 12.3.0+cvc.2 gets wasm and wasm-mt columns, so a host that links Python statically (ariglx-web, transfix/libcvc) can import PIL in the browser. linux, macos and windows don't change: those columns rebuild the same as cvc.2 and don't need repopulating.

This is the first part of phase W5 in transfix/libcvc's `docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md` (§10 Phases; the C-extension order is in §5.2, the wasm extension convention in §5.5). The libcvc side, a Pillow case in ariglx-web's browser smoke, is transfix/libcvc#1201.

## What it adds

- `build-wasm.sh` cross-builds Pillow the way numpy-cp312's does. A native python3.12 runs setup.py against the wasm CPython's sysconfigdata. The codecs are pinned as in build.sh: zlib, jpeg, tiff, freetype and webp on, everything else off.
- Each extension is linked closed (`emcc -shared` = `wasm-ld -r`) over the static closure from pkg-config. `_common/wasm_pyext.py` then localizes everything except the renamed PyInit. `share/python-wasm/pillow-cp312.inittab` lists `PIL._imaging`, `_imagingft`, `_imagingmath`, `_imagingmorph` and `_webp`. `_imagingtk` is dropped: a browser has no Tk.
- The script runs these gates on each flavor:
  - the manifest lists exactly those five extensions;
  - no undefined codec symbol (llvm-nm), and `wasm_pyext.py check`;
  - the codec archives' target_features (`wasm_features.py`, stdlib only). wasm-mt fails on a member that carries `-shared-mem`, because the relocatable link drops that marker and the probe can't see it; plain wasm prints what each archive carries;
  - a probe host (`wasm_probe.c`, `wasm_probe.py`) that links the objects with libpython (undefined symbols are errors) and runs PIL's codec round-trips and FreeType under node.

**CI doesn't test the new columns.** `pr-recipe-build-dev.yml` submits `--link shared`, and submit-dag skips the static-only platforms (wasm, wasm-mt, wasi, cosmo) for a shared link. Its platform list has no wasm-mt either. A green PR check therefore says nothing about wasm.

## How it was tested (sandipaws, Windows 11; the wasm builds in WSL Ubuntu-22.04, emsdk 5.0.7, python312 cvc.25, numpy-cp312 cvc.6)

- `tests/unit/test_pillow_wasm_features.py` (new; synthetic GNU and BSD archives): 10 passed.
- The recipe suites (`test_recipes`, `test_recipe_schema`, `test_validate_all_recipes`, `test_recipe_scripts_bash32`, `test_recipe_scripts_portable_sed`, `test_bundled_recipes`, `test_recipe_packaging_completeness`, `test_validate_recipe_dirs`, `test_recipe_coverage`) plus `test_wasm_pyext` and `test_pillow_wasm_features`: 210 passed, 4 skipped, 0 failed.
- `cvcpkg validate recipes/pillow-cp312`: all validations passed.
- black 24.10.0, ruff format and ruff check 0.6.9 on both new .py files: clean.
- WSL build and pack, wasm: the gate recorded 13 archives, the probe printed OK, the strict-glob pack rc=0; `wasm_pyext.py check` of numpy-cp312 + pillow-cp312 rc=0; `check_declared_files` returned [] (1/1 pass).
- WSL build and pack, wasm-mt: the gate passed with `--shared-memory` over 13 archives, the probe printed OK, pack rc=0; `wasm_pyext.py check` rc=0; `check_declared_files` returned [] (1/1 pass).
- Negative control: `wasm_features.py --shared-memory` on the plain wasm closure exits 1 and names the 6 `-shared-mem` members (pass).
- Negative control: a full wasm-mt build against a copy of its deps with the plain `libpng16.a` stops at the gate before the probe, naming `png.c.o` and `pngerror.c.o`, build rc=1 (pass).
- The libcvc PR's browser smoke ran the packed wasm bundle in ariglx-web in headless Chrome: all 10 cases passed, the Pillow one included.

Those builds used one directory as both `--prefix` and `--build-prefix`. build-wasm.sh reads only `CVC_DEPS_PREFIX`, and every library it links is a runtime edge, so the fleet's separate build prefix shouldn't matter.

## Left out

- **Publishing.** Nothing is populated. After review (Joe's call): populate-server with exactly `platforms=wasm,wasm-mt arch=wasm32 config=release link=static recipes=pillow-cp312 deps=false`. A `link=shared` dispatch stages no wasm job and goes green having published nothing.
- **libwebp's plain wasm column.** Every member of the plain-wasm libwebp, libsharpyuv, libwebpmux and libwebpdemux archives carries `+atomics`: that column was built with threads, which is why plain `_imaging` and `_webp` reference `pthread_*`. Building it with `WEBP_USE_THREAD=OFF` belongs in a separate libwebp recipe PR and is not on this branch.
- **ariglx-web's `depends.build`.** Adding `- name: pillow-cp312` there in libcvc waits until this bundle is published (a one-line follow-up). Until then libcvc's green `ariglx-web` check doesn't cover the Pillow case; the libcvc PR says so.

Merging waits on Joe's review.
@transfix
transfix merged commit 914b997 into master Nov 14, 2026
30 of 34 checks passed
@transfix
transfix deleted the feat/ox-wasm-pillow branch November 14, 2026 07:08
transfix added a commit that referenced this pull request Nov 14, 2026
…le-pick-upload

Conflicts, each side kept:
- ImGuiBackend.h: master's set_clipboard on the document's app, then this branch's pick_files
  and begin_frame.
- net_intrinsics.cpp: master's net verbs on the app with its OpenUrlLimit, then this branch's
  http-upload provider.

The upload follows #1203: perform() and http_starts_async() take the app, and the started
upload's StartedRequest gets the app it starts on (its go() calls cvc::net::start(*app, ...)).

Master's ariadne_runtime_test doesn't build: #1180's three rich-text cases call load_string
with one argument, and #1203 made it take the app. They pass their test's app now.
transfix added a commit that referenced this pull request Nov 14, 2026
…ted-gas

#1197 is in master as its squash, so the conflicts were #1197's own lines
against this branch's changes to them: this branch's are kept.

Two compile breaks on master, fixed here as #1203 fixed its own callers:
- ariadne_wasm_browser_test.cpp (#1197) called register_script_engine(engine)
  and unregister_script_engine("wasm"), which #1203 removed: the fixture
  registers nothing, as each test's AppRuntime calls use_script_engine.
- ariadne_runtime_test.cpp (#1180) called load_string(yaml), which #1203
  made load_string(app, yaml): the three calls pass the test's app.
transfix added a commit that referenced this pull request Nov 14, 2026
#1203 (no singletons) moved the URI registry, the HTTP client and options provider, the HTTP
cache's in-flight table, the net and OIDC hosts, the WebSocket table and open-url's clock onto
each app. This branch had changed the same code for threads. The merge keeps both:

- uri.h/uri.cpp: register_uri_handler and resolve take the app (#1203) and keep this branch's
  UriCancelled and UriLocalHandler; the http(s) handlers and the HTTP cache pass the request's
  cancel predicate through to the app's client.
- net_intrinsics.cpp: the providers stay by kind with each call on the calling program's host
  (ictx.host) and its finisher. The requests, fetch and WebSocket verbs take the app, the app's
  WsTable and its OpenUrlLimit (both app slots, got once at registration). open-url stays in its
  host_proxied provider, on the app's OpenUrlLimit instead of a clock of the provider's own.
- oidc_host.cpp: the refresh sends through the app's client with the asker's cancel predicate.
- ariadne.cpp: the Runtime's owner id is counted per app (#1203); has_snapshot asks the app's
  widget registry.
- allowlist.txt: master's (76 lines); the one line this branch removed is gone there too.

This branch's tests move onto the per-app APIs: the removed NetIntrinsicsGuard, L4Guard and
NetHostGuard go, set_http_client and send take the app, live_groups takes the app by reference,
and the worker pump counts come from the pool's stats (pool_stats::worker_pumps) where the
process-wide exec_pool_worker_pumps_total() was, in the tests, mt.ariadne_docs and the docs.
Also fixed: #1180's three rich-text tests called load_string without the app #1203 added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant