Skip to content

fix: cache the wasm runtime so offline actually works - #31

Merged
Endika merged 1 commit into
mainfrom
fix/cache-the-runtime
Aug 5, 2026
Merged

fix: cache the wasm runtime so offline actually works#31
Endika merged 1 commit into
mainfrom
fix/cache-the-runtime

Conversation

@Endika

@Endika Endika commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Reported from the app: the panel says ~30 MB, pressing descargar ahora leaves 19 MB cached. 19 MB is exactly the models — the WASM runtime was not being stored at all.

Online that is invisible, because the browser just refetches. Offline it is the difference between working and a blank screen, and "funciona sin conexión" is on the front page.

Stop trying to intercept MediaPipe

The service worker was supposed to catch MediaPipe's own WASM fetch via runtimeCaching. In practice it did not, and rather than guess at why, the app now fetches the engine files itself and cache.puts them into the same cache the service worker reads from. MediaPipe's later request is served from it either way.

The bug inside the fix

Warming needs to know which WASM build the browser will pick, since both ship and only one is downloaded. I wrote a SIMD feature-detect probe by hand — and it validated as false on Node, which fully supports SIMD.

A mis-declared body length made the module malformed, so it reported "no SIMD" everywhere. The fix would have cached the wrong 11 MB build and left the app exactly as broken offline, while looking like it worked. Now using the canonical bytes from wasm-feature-detect, with a test asserting the probe returns true — because the failure mode is silent and there is nothing else to catch it.

Also

  • Panel reports download progress per file instead of sitting on "Descargando…" through 30 MB.
  • report() exposes hasRuntime, and the panel says outright when weights are cached without the runtime.
  • engineUrls() respects BASE_URL — a leading slash would 404 on Pages, which serves from /esku/.

@Endika
Endika merged commit 0daeeb9 into main Aug 5, 2026
7 checks passed
@Endika
Endika deleted the fix/cache-the-runtime branch August 5, 2026 23:12
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