Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 3 min read

Five things that broke when I moved 356 file tools into the browser

I build Madosuite, a set of PDF, image, video and office tools where the work happens in the page. Your file is never uploaded: QPDF, Tesseract, ONNX Runtime and a few Rust crates run in WebAssembly or WebGPU on your own

I build Madosuite, a set of PDF, image, video and office tools where the work happens in the page. Your file is never uploaded: QPDF, Tesseract, ONNX Runtime and a few Rust crates run in WebAssembly or WebGPU on your own machine.

The tools themselves were the easy part. Getting big models and wasm builds to load reliably in every browser was not. Here are five bugs that cost me the most time, and what fixed them.

1. Safari gave up on big downloads

The background-removal model, the OCR language files and the PDF summarizer's language model are large. The summarizer's model alone is 3.35 GB. In Chrome a single fetch was fine. In Safari, big or parallel downloads from my host would fail part-way with a bare "Load failed", and the user had to start again.

What fixed it: every model is cut into 8 MiB parts at build time, listed in an index with their hashes. The page fetches parts through one global queue, a few at a time, and retries each part up to four times. A failed part costs 8 MiB, not 3 GB. The 3.35 GB model is 400 parts, and Safari now gets through all of them in a bit over two minutes on a good connection.

2. The CDN kept old headers on new files

OCR worked locally and failed only in production. The cause was a header, not code. Threaded wasm needs Cross-Origin-Embedder-Policy, and the CDN had cached an old response for a file whose bytes hadn't changed, headers included. New deploy, same bytes, stale headers.

What fixed it: file names carry their content hash, and so do the folders. When anything about how a file must be served changes, its address changes too, and no cache can hand back the old one.

3. iPhone showed "WebKitBlobResource error 1" instead of the page

A service worker keeps pages and scripts so tools open offline. On some iPhones the page was replaced by that error. A stored response had been cut short, or emptied by the system to free space. The service worker handed it back as if it were whole.

What fixed it: the worker stores a copy only after the whole body has arrived. When it serves a stored copy, it reads it fully into memory first. If that read fails, it deletes the entry and goes to the network.

4. Two runs on one WebGPU session hang forever

Choosing a photo starts background removal at once. If you then pressed the button while it was still running, a second inference started on the same ONNX Runtime WebGPU session, and both waited forever. No error, just "Working…" until you reloaded.

What fixed it: one queue per model session in the worker, so a second run waits for the first. A double press now finishes both in under ten seconds.

5. Picking a small language model by measuring it

I wanted the PDF summary to read like prose, in whatever language the PDF is in, on the user's own GPU. I gave three small models the same 45 jobs: 15 languages, 3 documents each. Then I read every output and counted the ones that got a fact wrong.

Model Summaries with a factual slip
Gemma 4 E2B (q4_0) 6 / 45
Qwen3.5 2B (q4) 29 / 45
Qwen3.5 0.8B (q8) 32 / 45

Gemma won clearly, but 6 in 45 is still not zero. So the rewrite never replaces the extracted sentences, it sits under them. Sentences that mention a number or a name that isn't in the PDF are removed. If the model answers in the wrong language or starts repeating itself, the page keeps the extracted summary. It is offered only where the model fits in memory; it needed about 3.8 GB of GPU memory when I measured it, so phones don't get the button.

What I'd tell someone starting the same thing

  • Test Safari on a real network early. Local tests won't show the download failures.
  • Put a hash in every name you serve, folders included.
  • Assume anything in browser storage can come back broken.
  • Measure a model on your own task before you trust a leaderboard.

If you try the tools and one fails on your file, tell me in the comments. I fix those first.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.