TT Lab
Blog

한국어 English 日本語 中文

Get started
Blog

Blog

Running inside Phones and Browsers: WebGPU, WASM, WebNN, Core ML, and What to Do Where

Status: Draft (2026-10-16), mostly based on documentation. There are no measurementsof running our models inside phones and browsers. Standards and browser support were verified on 2026-10-16 using official W3C and browser vendor publications. JPEG sizes and model parameter counts were taken from server measurements in this series. Part 7 of the series "Reading Vision Models 3". The format for carrying models (ONNX) is covered in Part 3.

Table of Contents

1. Intuition: Where to Compute

The camera is on the phone, and the results (scoreboard) appear on the phone screen. If only the model in between sits on the server, every frame requires a phone → server → phone round trip. Moving the model to the phone eliminates this round trip. However, phones have smaller GPUs, heat up under sustained workloads, and vary in performance by up to ten times across models.

폰에서 할 일, 서버에서 할 일 폰(브라우저) 카메라 잡기 30fps 512×288 로 줄이기 JPEG 인코딩 점수판·공 그리기 서버(GPU) JPEG 풀기·정규화 공 모델(창 3장) 바운드·심판 규칙 탁구대 찾기 올림: 프레임 JPEG × 30장/초 — 대역은 본문 표 내림: 공 위치·판정 JSON — 수백 바이트 기기 안에서 돌리면 망 지연·서버 비용 없음 영상이 폰 밖으로 안 나감 배터리·열·기기마다 다름 서버에서 돌리면 큰 모델, 같은 결과 고치면 모두에게 바로 망 왕복·대역·GPU 비용
Figure: Current division where the phone (browser) handles capturing, resizing, JPEG encoding, and rendering, while the server (GPU) handles JPEG decoding, the ball model, bounding, referee rules, and table detection. Below are the pros and cons of running on-device versus on the server.
On-Device On the Server
Latency No network round trip Network round trip + relay
Privacy Video does not leave the device Frames are sent to the server (even if not stored)
Cost Computed by the user's device Server GPU costs, concurrent user limits
Model Must be small (download and memory constraints) Can be large
Consistency Speed and results may vary by device model Identical results for everyone
Updates New model must be downloaded again Changing the server updates it for everyone

2. The Path to Browser Computation

WebGL → WebGPU

TensorFlow.js (Smilkov et al., 2019) ran neural networks using the browser's graphics API (WebGL). It was a workaround that packed tensors into textures and ran a graphics shader once per output element. Even so, the performance difference was substantial.

MobileNet v1, single 224×224 run (Paper Table 1) Time
Pure JavaScript (2014 laptop) 3,426ms
WebGL, integrated GPU on the same laptop 49ms (71x)
WebGL, desktop-class GPU 5ms (685x)
Node.js, 같은 데스크톱급 GPU 의 CUDA 3ms

WebGPU is a new standard that invokes GPU computations directly without borrowing a graphics API. Its shader language is WGSL. As of 2026-10-16, both WebGPU and WGSL are at the "Candidate Recommendation Draft" stage at W3C (versions dated 2026-09-15 and 2026-09-21, respectively). Releases confirmed via official browser vendor posts are as follows.

Browser WebGPU Enabled by Default
Chrome 113 ChromeOS, macOS, Windows
Chrome 121 Android 12 or later (devices with Qualcomm and ARM GPUs)
Safari 26.0 macOS, iOS, iPadOS, visionOS
Firefox 141 Windows only (based on a 2025-07 post; other operating systems not verified since)

MDN still marks it as "Limited availability" and restricts its use to secure contexts like HTTPS. 16-bit floating point (f16) has been used on devices with shader support since Chrome 120. Essentially, the FP16 from Part 2 has become viable in browsers as well.

WebAssembly (WASM): Utilizing the CPU Properly

Because offloading to the GPU incurs a fixed overhead, the CPU can win for smaller models. WebAssembly is the path to fast CPU execution in browsers, and enabling SIMD (single instruction, multiple data) and threads makes a dramatic difference. Below is a table from the official TensorFlow.js repository's WASM backend (Chrome 79, older figures from around 2020 hardware).

MobileNet V2, 2019 laptop Time
Pure JavaScript 893.5ms
WASM 98.4ms
WASM + SIMD 30.2ms
WASM + SIMD + Threads 10.3ms
WebGL 19.6ms

The same document notes that for lightweight models requiring 20 million to 60 million multiply-accumulate operations, WASM performs similarly to WebGL, whereas for 100 million to 500 million operations, WASM is several times slower. The tradeoff between "invocation overhead versus computation" seen in Part 3 applies equally in the browser.

WebNN: Device Neural Network Accelerators

Modern phones and laptops feature dedicated neural network accelerators (NPUs). These cannot be utilized via WebGPU. WebNN is a W3C standard that passes computational graphs using neural network operation units like "convolution" and "matrix multiplication" so that the browser can execute them on the appropriate hardware among CPU, GPU, or NPU. The 2026-10-10 version is a Candidate Recommendation Draft, and in the current version, developers specify preferences such as "low power" or "high performance" rather than choosing hardware directly. Default release status per browser could not be verified through primary sources.

ONNX Runtime Web: One File, Multiple Backends

This is a runtime for running the ONNX files from Part 3 in the browser. Execution providers include wasm(CPU) andwebgpu·webgl·webnn , and since only WASM supports all operators, operations unsupported by other providers fall back to WASM. The WebGL provider is maintained only for legacy purposes, with WebGPU recommended for performance (according to official documentation). The browser support table in this document appeared older than the vendor posts above—stating that "the runtime has been tested in that browser" is distinct from "the browser has shipped WebGPU."

3. In Apps: Core ML

Apple's Core ML utilizes the CPU, GPU, and Neural Engine concurrently. Setting computeUnits to "All" allows the operating system to select the hardware, while developers can narrow it down to CPU only, CPU+GPU, or CPU+Neural Engine. The model compression tool (coremltools) provides weight palettization (1-, 2-, 3-, 4-, 6-, 8-bit lookup tables), INT4 and INT8 weight quantization, INT8 activation linear quantization, and pruning. The documentation notes that while compression reliably reduces size, it "does not guarantee latency gains" (as some backends dequantize weights for computation) and recommends re-evaluating on your own model and device—reaching the same conclusion as Parts 2 and 4. latency gains are not guaranteed(some backends dequantize weights before computing)

4. Models Already Running on Phones

Their common trait is small models + less frequent execution . Achieving real-time performance on phones is more a matter of pipeline design than simply speeding up a single model.

5. Porting Our Model to the Phone: Size and Bandwidth

Model Parameters FP32 FP16 INT8
Ball Model (BlurBall) 1.49M 6.0MB 3.0MB 1.5MB
Table Detection (EfficientTAM-S) 34.06M 136MB 68MB 34MB

(Parameter count × 4, 2, 1 bytes. Actual files include additional structural metadata.)

The ball model is small enough to be downloaded alongside a webpage without issue. The challenge is computation. Because this model maintains a 512×288 resolution throughout, it took approximately 10ms per FP16 inference even on a server-grade laptop GPU (Part 1). Whether it can achieve 30fps on a phone GPU was not measured (unmeasured). Since table detection only needs to run once at the start of a match, hundreds of milliseconds on the phone is acceptable, but downloading 34–136MB is required.

Conversely, running on the server as we currently do requires uploading frames. Server measurements from this series showed the following JPEG sizes for the same match footage:

Transmitted Screen Quality 50 Quality 70 Quality 90 Sending at 30fps (Quality 70)
512×288 9.1KB 12.3KB 24.7KB approx. 2.9Mbit/s
1280×720 37.7KB 52.4KB 111.5KB approx. 12.6Mbit/s

(Based on the server CPU's OpenCV encoder. Browser JPEG encoders may yield different sizes at the same quality setting—operational design documentation measured 12–18KB for match video.) Simply scaling down to 512×288 reduces bandwidth to one-fourth. In table tennis venues with slow upload Wi-Fi, this difference determines whether the system works or fails.

6. Limitations

7. Connection to Our Project

The next post is an actual budget table putting all the pieces of this series together into a single real-time TT Score pipeline.

TT's Word. My ball model is 6MB so it fits right into the phone. But nobody has measured yet whether it can actually think 30 times a second inside the phone. I won't say it "works" until I measure it!

References

Sign in to like

Comments

No comments yet.

Sign in to leave a comment