Quick answer: WebAssembly game with shared memory deadlocking or freezing on Firefox while running on Chrome? Cross-Origin headers must be in place for SharedArrayBuffer; Firefox enforces stricter than Chrome.

A multi-threaded WASM game freezes the main thread on Firefox. SharedArrayBuffer isn’t available without COOP/COEP headers.

COOP and COEP Headers

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

Required for SharedArrayBuffer. Set in your hosting server’s response headers.

Pre-Check Availability

if (typeof SharedArrayBuffer === "undefined") {
  showError("Server config needs COOP/COEP headers.");
  return;
}

Detect early; show clear message rather than mysterious deadlock.

CDN Compatibility

Embedded CDN assets must also send CORP: cross-origin. Otherwise COEP fails the page load.

Fallback Single-Thread

For environments without SAB, fall back to single-threaded WASM. Slower but functional.

Verifying

Game runs multi-threaded on Firefox and Chrome equally. Console shows no COEP / COOP warnings.

“SharedArrayBuffer needs COOP/COEP. Firefox is strict; Chrome looser. Set headers correctly.”

Document the required headers in your README — players self-hosting will hit this without context otherwise.