When building Pixly, one of the biggest architectural decisions was choosing the compute backend. WebGPU offers GPU acceleration, while WebAssembly provides portable CPU performance. We benchmarked both extensively — here are the results.
The Contenders
WebGPU is the new web standard for low-level GPU access. It replaces WebGL for general-purpose compute and offers dramatically better performance for parallel workloads. WebAssembly (WASM), on the other hand, runs compiled code at near-native speed on the CPU.
Benchmark Setup
We tested four common image processing operations on a 12-megapixel image, running each 10 times and taking the median. The test machine was a MacBook Pro M2 with 16GB RAM.
// Benchmark results (ms, lower is better)
// WebGPU WASM WebGL (legacy)
// BG Removal 2,300 8,500 5,200
// 4x Upscale 3,200 12,000 7,800
// Compression 180 450 320
// Format Convert 90 220 150 When WebGPU Wins
WebGPU dominates in parallel workloads — anything that processes millions of pixels simultaneously. Background removal with U²-Net runs 3.7x faster on WebGPU than WASM. Upscaling with ESRGAN is 3.75x faster. The GPU's thousands of cores make short work of convolution operations.
When WASM Wins
WASM has its strengths. For sequential operations with complex control flow — like entropy coding in compression — WASM can be more efficient. It also has universal browser support, while WebGPU is still rolling out. And for smaller images, the overhead of GPU dispatch can make WASM faster.
- WebGPU: 3-4x faster for ML inference and convolution
- WASM: Better for sequential algorithms and small images
- WebGL: Fallback when WebGPU is unavailable
- Hybrid approach: Use the best backend per operation
The answer isn't WebGPU or WASM — it's both. We use WebGPU for ML models and WASM for encoding, with WebGL as a fallback. The right tool for each job.
Our Architecture
Pixly uses a hybrid approach. We detect WebGPU support at runtime and use it for ML inference (background removal, upscaling). For compression and format conversion, we use WASM-compiled codecs. If WebGPU isn't available, we fall back to WebGL for ML and WASM for everything else.
The Future
As WebGPU support expands and the API matures, we expect to move more operations to the GPU. But WASM will remain essential for codecs and sequential algorithms. The hybrid approach gives us the best of both worlds — and the best experience for our users.
Device-Specific Results
Performance varies significantly across hardware. Our benchmarks were on an M2 MacBook Pro, but we also tested on Windows machines, older Macs, and budget laptops. The relative performance gap between WebGPU and WASM remains consistent across devices, but absolute times vary. A budget laptop with integrated graphics might take 8 seconds for background removal on WebGPU versus 25 seconds on WASM — still a 3x improvement.
| Device | WebGPU BG Removal | WASM BG Removal | Speedup |
|---|---|---|---|
| MacBook Pro M2 | 2.3s | 8.5s | 3.7x |
| MacBook Air M1 | 3.1s | 11.2s | 3.6x |
| Dell XPS 15 (i7) | 3.8s | 14.1s | 3.7x |
| Budget laptop (i3) | 8.2s | 25.4s | 3.1x |
| Chromebook (ARM) | 5.6s | 18.3s | 3.3x |
Key Finding
WebGPU provides a consistent 3-4x speedup over WASM for ML inference across all tested devices. The relative improvement is hardware-independent, meaning WebGPU benefits low-end devices as much as high-end ones — which is crucial for accessibility.
Memory Usage Comparison
Performance is not the only consideration — memory usage matters too, especially for users on devices with limited RAM. WebGPU uses GPU memory, which is separate from system RAM, meaning ML inference does not compete with browser tabs for memory. WASM, on the other hand, uses system RAM, which can lead to tab crashes on memory-constrained devices.
- WebGPU uses dedicated GPU memory (VRAM) — does not compete with browser tabs
- WASM uses system RAM — can cause memory pressure on low-end devices
- WebGL uses GPU memory but with higher overhead than WebGPU
- All three backends cache models in IndexedDB after first download
If your browser tab crashes during processing, it is almost always a memory issue. Try closing other tabs, using a smaller image, or switching to a browser with WebGPU support to leverage GPU memory instead of system RAM.
You can check which backend Pixly is using by opening the console (F12). We log the detected backend on page load: "Pixly: Using WebGPU backend" or "Pixly: Using WebGL fallback" or "Pixly: Using WASM backend".
Key Takeaways
- WebGPU is 3-4x faster than WASM for ML inference across all tested devices
- WASM is better for sequential algorithms like entropy coding in compression
- WebGPU uses GPU memory, reducing memory pressure on system RAM
- Pixly uses a hybrid approach: WebGPU for ML, WASM for codecs, WebGL as fallback
- Backend selection is automatic — users do not need to configure anything