test: ogv.js WebM polyfill for Safari VP9 playback#271
test: ogv.js WebM polyfill for Safari VP9 playback#271devin-ai-integration[bot] wants to merge 1 commit intoperf/optimize-landing-assetsfrom
Conversation
On Safari/iOS, VP9 WebM doesn't play natively. Instead of falling back to lower-quality MP4, use ogv.js (WASM VP9 decoder, ~444KB) to play WebM on Safari via canvas rendering. - Add WebMVideo component that detects Safari and loads ogv.js - Chrome/Firefox use native <video> with WebM (no overhead) - Safari loads ogv.js WASM files from /ogv/ on demand - Keep MP4 as ultimate fallback if ogv.js fails to load Co-Authored-By: Junho Yeo <i@junho.io>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| const player = new OGVPlayer(); | ||
| player.src = webmSrc; | ||
| player.muted = !!muted; | ||
| player.loop = !!loop; |
There was a problem hiding this comment.
🔴 OGVPlayer ignores loop — videos won't loop on Safari
The ogv.js OGVPlayer class has a no-op loop setter (loop:{get:function getLoop(){return!1},set:function setLoop(t){}}), so player.loop = !!loop at line 113 is silently ignored. On Safari/iOS (the ogv.js path), both the hero video and trophy cup video will play once and stop instead of looping continuously. The native <video> path (Chrome/Firefox) works correctly because the HTML video element supports loop natively. The component should listen for the ended event on the ogv player and manually restart playback when loop is true, similar to how autoPlay is manually handled via player.play() at WebMVideo.tsx:124-128.
| const player = new OGVPlayer(); | |
| player.src = webmSrc; | |
| player.muted = !!muted; | |
| player.loop = !!loop; | |
| const player = new OGVPlayer(); | |
| player.src = webmSrc; | |
| player.muted = !!muted; | |
| player.loop = !!loop; | |
| // OGVPlayer's loop setter is a no-op, so manually implement looping | |
| if (loop) { | |
| player.addEventListener("ended", () => { | |
| player.stop(); | |
| player.src = webmSrc; | |
| player.play().catch(() => {}); | |
| }); | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
test: ogv.js WebM polyfill for Safari VP9 playback
Summary
Adds a
WebMVideoReact component that uses ogv.js (WASM-based VP9 decoder, ~444KB) to play WebM videos on Safari/iOS, where native VP9 WebM playback is unreliable. Chrome/Firefox continue using native<video>with zero overhead.This is a test branch for comparison against
test/mp4-high-quality(higher quality MP4 fallback approach). Not intended for direct merge without Safari verification.How it works:
WebMVideodetects Safari via user-agent sniffingOGVPlayerinstance → renders WebM via WASM decoder to canvas<video>with<source>tags (WebM first, MP4 fallback)<video>with MP4Review & Testing Checklist for Human
<div>(not<video>) with an ogv.js canvas inside. The CSS fromstyled(WebMVideo)(fixed 552×552 hero, absolute-positioned 396×396 trophy) may not apply correctly to this different DOM structure. Check for layout breakage.WebMVideoinstances exist on the page (hero + trophy). The current implementation injects the ogv.js<script>tag in each component'suseEffectwith no deduplication. This likely loads ogv.js twice.window.OGVPlayerasHTMLVideoElement(it's not) and usesinnerHTML = ""to clear the container ref (React anti-pattern). These are functional shortcuts that may cause subtle issues.Notes
public/ogv/— no npm dependency due to platform restrictionsSummary by cubic
Adds a WebMVideo component that enables reliable VP9 WebM playback on Safari/iOS using ogv.js, while keeping native
Written for commit 87a2254. Summary will update on new commits.