Skip to content

feat: Add COOP/COEP Headers for Cross-Origin Isolation & FFmpeg Multi-Threading#998

Merged
magic-peach merged 1 commit into
magic-peach:mainfrom
Abhi190702:feat/coop-coep-ffmpeg-multithreading
May 23, 2026
Merged

feat: Add COOP/COEP Headers for Cross-Origin Isolation & FFmpeg Multi-Threading#998
magic-peach merged 1 commit into
magic-peach:mainfrom
Abhi190702:feat/coop-coep-ffmpeg-multithreading

Conversation

@Abhi190702
Copy link
Copy Markdown
Contributor

Summary

Resolves #601

Adds COOP/COEP headers to enable cross-origin isolation and FFmpeg.wasm multi-threaded mode when the deployed host supports it.

Problem

self.crossOriginIsolated currently returns false on the deployed site, forcing FFmpeg.wasm into single-threaded mode. A 1-minute 1080p export can take 3–5 minutes instead of ~30–60 seconds.

Changes Made

vercel.json

  • Added Cross-Origin-Opener-Policy: same-origin
  • Added Cross-Origin-Embedder-Policy: require-corp
  • Preserved all existing routes and security headers

public/_headers

  • Added the same headers for Netlify / Cloudflare Pages support

src/lib/ffmpeg.ts

  • Added self.crossOriginIsolated runtime check
  • Loads @ffmpeg/core-mt when isolated
  • Falls back to @ffmpeg/core when not isolated
  • Keeps graceful degradation for hosts that cannot enable isolation

CONTRIBUTING.md

  • Documented the GitHub Pages limitation for custom headers

Why NOT next.config.ts

This project uses output: 'export' (static export). The headers() function in next.config.ts is silently ignored in static mode. Headers are correctly placed in vercel.json as confirmed by the maintainer.

Performance Impact

Mode Export time (1-min 1080p)
Before (single-threaded) ~3–5 minutes
After (multi-threaded) ~30–60 seconds

Testing

After deployment, run in DevTools console:
self.crossOriginIsolated -> should return true

Local checks:

  • bun run lint
  • bunx tsc --noEmit
  • bun run build

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

Someone is attempting to deploy a commit to the magic-peach1's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @Abhi190702!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

@github-actions github-actions Bot added level:beginner Beginner level - 20 pts type:performance Performance type:security Security type:testing Testing labels May 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ PR Format Check Passed — @Abhi190702

Basic format checks passed. A maintainer will review your code changes.

This does not mean the PR is approved — it just means the format is correct.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
reframe Ready Ready Preview, Comment May 23, 2026 10:15am

@Abhi190702
Copy link
Copy Markdown
Contributor Author

Abhi190702 commented May 23, 2026

@magic-peach , Hey I would be grateful if you could look into this
:)
Edit - Please can you add GSSOC tag , so that contribution might count in it thanks

@magic-peach magic-peach added gssoc:approved Approved for GSSoC'26 quality:clean Well-implemented, clean code labels May 23, 2026
@magic-peach magic-peach merged commit 6c51b50 into magic-peach:main May 23, 2026
12 checks passed
chavanGaneshDatta pushed a commit to chavanGaneshDatta/reframe that referenced this pull request May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for GSSoC'26 level:beginner Beginner level - 20 pts quality:clean Well-implemented, clean code type:performance Performance type:security Security type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add COOP/COEP headers to enable multi-threaded FFmpeg (5–10× faster exports)

2 participants