The COEP Header That Quietly Turns Off Your Pose Model's Threads

Relax one response header to fix an embedded reference video, and the browser withdraws SharedArrayBuffer from the page. The WebAssembly pose runtime notices, falls back to a single thread and keeps running. Nothing throws, the diff looks reasonable, and the only symptom is a scoring loop that slowly falls behind the dancer.

Why the review passes

The change usually arrives as a proxy config edit with a sensible commit message: the reference video from a third-party host refuses to load under Cross-Origin-Embedder-Policy require-corp, so someone deletes the header. Reviewers read a one-line diff in the reverse proxy, confirm the video plays, and approve. What the diff does not show is that cross-origin isolation, which the browser isolation policies COOP and COEP grant only together, is the gate for SharedArrayBuffer, and without it the WASM backend cannot spawn its worker threads. The runtime treats this as a capability probe, not an error, loads the single-threaded build and logs nothing anyone reads. A fix for one component has degraded another that shares no code with it.

What the failure looks like from the user's side

At 30 fps the camera gives the pose stage a budget of 33 ms per frame, and a threaded WASM or WebGPU backend fits inside it on an ordinary laptop. On the single-threaded path, inference typically takes two to four times longer, an estimate that varies widely by device, so the loop starts skipping frames. If playback and inference share one requestAnimationFrame callback, the reference video stutters as well and the user blames their connection. If the two loops are decoupled, the video stays smooth while the score is computed from a thinning sample of frames: better for the dancer, worse for detection, because the page looks perfectly healthy.

A check you can run today

Open the production page, open DevTools and evaluate crossOriginIsolated; if it returns false, the threaded backend is off for every visitor, whatever staging says. To see the cause in the same console, run fetch(location.href,{method:'HEAD'}).then(r=>console.log(r.headers.get('cross-origin-embedder-policy'), r.headers.get('cross-origin-opener-policy'))) and compare the output with what the proxy config is supposed to send. Put the crossOriginIsolated expression in a headless browser step after every deploy and fail the pipeline when it is false, because a plain header grep on one route will not catch the route someone added last week. None of this needs camera frames to leave the device: a boolean and a timing histogram are enough. The decision rule is blunt: crossOriginIsolated false in production is a release blocker, not a performance ticket.

Keeping the session usable when the backend degrades

Have the app display its active backend and p95 inference time, drop model complexity before it drops frames, and switch the video host to COEP credentialless where the browser supports it instead of deleting the header, which leaves you one trade-off to own: a third-party embed that loads without cookies, a price a privacy-first trainer should accept without much argument.

Why not serve the reference videos from our own origin and skip the negotiation?

When licensing allows it, that is the cleanest fix: same-origin media needs no CORP header from anyone else, and the isolation policy can stay strict. The cost moves to bandwidth and storage you now operate yourself.

Back to DanceHeal · Domains

← Back to DanceHeal
Engineering & Architecture Brief

The COEP Header That Quietly Turns Off Your Pose Model's Threads

Relax one response header to fix an embedded reference video, and the browser withdraws SharedArrayBuffer from the page. The WebAssembly pose runtime notices, falls back to a single thread and keeps running. Nothing throws, the diff looks reasonable, and the only symptom is a scoring loop that slowly falls behind the dancer.

Why the review passes

The change usually arrives as a proxy config edit with a sensible commit message: the reference video from a third-party host refuses to load under Cross-Origin-Embedder-Policy require-corp, so someone deletes the header. Reviewers read a one-line diff in the reverse proxy, confirm the video plays, and approve. What the diff does not show is that cross-origin isolation, which the browser isolation policies COOP and COEP grant only together, is the gate for SharedArrayBuffer, and without it the WASM backend cannot spawn its worker threads. The runtime treats this as a capability probe, not an error, loads the single-threaded build and logs nothing anyone reads. A fix for one component has degraded another that shares no code with it.

What the failure looks like from the user's side

At 30 fps the camera gives the pose stage a budget of 33 ms per frame, and a threaded WASM or WebGPU backend fits inside it on an ordinary laptop. On the single-threaded path, inference typically takes two to four times longer, an estimate that varies widely by device, so the loop starts skipping frames. If playback and inference share one requestAnimationFrame callback, the reference video stutters as well and the user blames their connection. If the two loops are decoupled, the video stays smooth while the score is computed from a thinning sample of frames: better for the dancer, worse for detection, because the page looks perfectly healthy.

A check you can run today

Open the production page, open DevTools and evaluate crossOriginIsolated; if it returns false, the threaded backend is off for every visitor, whatever staging says. To see the cause in the same console, run fetch(location.href,{method:'HEAD'}).then(r=>console.log(r.headers.get('cross-origin-embedder-policy'), r.headers.get('cross-origin-opener-policy'))) and compare the output with what the proxy config is supposed to send. Put the crossOriginIsolated expression in a headless browser step after every deploy and fail the pipeline when it is false, because a plain header grep on one route will not catch the route someone added last week. None of this needs camera frames to leave the device: a boolean and a timing histogram are enough. The decision rule is blunt: crossOriginIsolated false in production is a release blocker, not a performance ticket.

Keeping the session usable when the backend degrades

Have the app display its active backend and p95 inference time, drop model complexity before it drops frames, and switch the video host to COEP credentialless where the browser supports it instead of deleting the header, which leaves you one trade-off to own: a third-party embed that loads without cookies, a price a privacy-first trainer should accept without much argument.

Technical FAQ: Why not serve the reference videos from our own origin and skip the negotiation?

When licensing allows it, that is the cleanest fix: same-origin media needs no CORP header from anyone else, and the isolation policy can stay strict. The cost moves to bandwidth and storage you now operate yourself.

Related Architecture Specifications (DANCEGOAL): fitnessdetection.com · morningparties.club · salsamethod.com