From 0572bbde72514a9584b19fe031a03d4c9b23d74c Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Tue, 6 Oct 2026 23:18:38 +0200 Subject: fix(hub): play video on iPhone through ManagedMediaSource An iPhone has no MediaSource; every film was refused as an unsupported codec. A browser with neither now says so. Co-Authored-By: Claude Opus 5.5 --- docs/MESHBAY_DESIGN.md | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/de.js | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/en.js | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/es.js | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/fr.js | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/it.js | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/ja.js | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/nl.js | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/pl.js | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js | 1 + .../meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js | 1 + .../meshbay-hub/src/meshbay_hub/static/video-player.js | 16 ++++++++++++++-- 12 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/MESHBAY_DESIGN.md b/docs/MESHBAY_DESIGN.md index fdf08f9..8d6a18c 100644 --- a/docs/MESHBAY_DESIGN.md +++ b/docs/MESHBAY_DESIGN.md @@ -4049,6 +4049,7 @@ process runs it — `systemctl --user` on Linux, Task Scheduler on Windows. | **Listing a group's folders walks every root on the event loop** | `index_sync_message` (`transport/wire.py`) builds its `dirs` field with `list_dirs`, an `rglob("*")` over every root, and nothing sends it off the loop: the WebRTC `index_sync` handler, the daemon's index push and QUIC all call it inline. So each index request from any member is a directory walk of the whole library that every other peer on the node waits behind. `test_disk_io_off_loop.py` never saw it, because it reads the transport's own modules and the walk is one call away in `wire.py`. Found by widening what that test reads, not by a symptom | | **A loopback eject or plug reaches open pages late** | `ops.eject_root` and `ops.plug_root` flip the live set and tell nobody; over MNP the broadcast `root_eject_ack` / `root_plug_ack` is what moves every open table. So an eject made from the desktop application or the CLI shows on members' pages only with the next index push — for a plug, the end of its rescan; for an eject, whatever changes next. `ops.update_root` had the same silence and now calls `DirectoryIndexer.publish_roots`; the same call belongs in these two. Found while moving the `writable`/`removable` switches to the loopback door (MNP 6.0) | | **A group key rotated from the Node page leaves the chat key where it was** | `ops.set_gek(rotate=True)` replaces the group key and opens no chat epoch; the MNP `gek_rotate` handler opened one itself (`_new_chat_epoch`), and it was the only door that did — but no client ever sent it, and it is gone since 6.0. The removals that matter (revoke, unpin, device revoke) open an epoch in `ops` for every door, so what is missing is the follow-through for an operator who rotates by hand: §4.5's "rotate after a removal" means it for chat too. The fix is the `_after_removal` shape — `open_chat_epoch` inside `ops.set_gek` when `rotated`. Found while removing the MNP message | +| **iPhone playback is untested, and the player ignores what ManagedMediaSource asks of it** | An iPhone has no `MediaSource`, only `ManagedMediaSource` (iOS 17.1+), which `video-player.js` now falls back to; below 17.1 nothing plays. Nobody has watched a film on one yet. The player listens for neither `startstreaming`/`endstreaming` nor `bufferedchange`, and the browser may evict buffered ranges on its own, ahead of the playhead included: the read-ahead (`pump()`, `currentRange()`) assumes a buffer only it shrinks. AirPlay is switched off on that path, because the source never opens otherwise | | **The transcoded-seek test passes without transcoding** | `test_a_transcoded_video_keeps_accurate_seeking` (`test_stream_seek_audio_alignment.py`) forces the re-encode branch by swapping the module's `BROWSER_INCOMPATIBLE_VIDEO_CODECS`, then checks only that the result has no audio gap. The copy path also leaves no gap on that clip, so pointing the swap at a module the streaming code does not read still passes: the test cannot tell that the branch it is named after never ran. It should assert the re-encode happened (the `re-encoding` log line, or the encoder in the ffmpeg argv). Found by breaking the swap on purpose while moving the streaming code | --- diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js index 6e42af9..f4151f7 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js @@ -283,6 +283,7 @@ export default { 'group.upload_indexing': 'wird indiziert …', 'video.err_transport': 'Transport nicht verbunden', 'video.err_mse': 'Codec wird für das Streaming nicht unterstützt: {codec}', + 'video.err_no_mse': 'Dieser Browser kann keine Videos streamen (auf dem iPhone ist iOS 17.1 oder neuer nötig)', 'video.mode_poster': 'Poster', 'video.mode_flat': 'Flache Liste', 'video.filter_all': 'All', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js index f94b438..84607e7 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js @@ -281,6 +281,7 @@ export default { 'group.upload_indexing': 'indexing…', 'video.err_transport': 'Transport not connected', 'video.err_mse': 'Codec not supported for streaming: {codec}', + 'video.err_no_mse': 'This browser cannot stream video (an iPhone needs iOS 17.1 or later)', 'video.mode_poster': 'Posters', 'video.mode_flat': 'Flat list', 'video.filter_all': 'All', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js index 6ff8be2..28ad85e 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js @@ -281,6 +281,7 @@ export default { 'group.upload_indexing': 'indexando…', 'video.err_transport': 'Transporte no conectado', 'video.err_mse': 'Códec no compatible con la reproducción en continuo: {codec}', + 'video.err_no_mse': 'Este navegador no puede reproducir vídeo en continuo (un iPhone necesita iOS 17.1 o posterior)', 'video.mode_poster': 'Pósteres', 'video.mode_flat': 'Lista plana', 'video.filter_all': 'All', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js index 9132bd2..9e8dbbe 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js @@ -282,6 +282,7 @@ export default { 'group.upload_indexing': 'indexation…', 'video.err_transport': 'Transport non connecté', 'video.err_mse': 'Codec non pris en charge pour la diffusion : {codec}', + 'video.err_no_mse': 'Ce navigateur ne sait pas diffuser de vidéo (un iPhone doit être en iOS 17.1 ou plus récent)', 'video.mode_poster': 'Affiches', 'video.mode_flat': 'Liste à plat', 'video.filter_all': 'Tous', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js index f3ff714..493455d 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js @@ -282,6 +282,7 @@ export default { 'group.upload_indexing': 'indicizzazione…', 'video.err_transport': 'Trasporto non connesso', 'video.err_mse': 'Codec non supportato per lo streaming: {codec}', + 'video.err_no_mse': 'Questo browser non può riprodurre video in streaming (un iPhone richiede iOS 17.1 o successivo)', 'video.mode_poster': 'Locandine', 'video.mode_flat': 'Elenco semplice', 'video.filter_all': 'All', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js index 0690034..35a639a 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js @@ -279,6 +279,7 @@ export default { 'group.upload_indexing': 'インデックスを作成中…', 'video.err_transport': 'トランスポートが接続されていません', 'video.err_mse': 'ストリーミング再生に対応していないコーデックです:{codec}', + 'video.err_no_mse': 'このブラウザーは動画のストリーミング再生に対応していません(iPhone では iOS 17.1 以降が必要です)', 'video.mode_poster': 'ポスター表示', 'video.mode_flat': 'フラット表示', 'video.filter_all': 'All', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js index ce6312c..73731cf 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js @@ -283,6 +283,7 @@ export default { 'group.upload_indexing': 'indexeren…', 'video.err_transport': 'Transport niet verbonden', 'video.err_mse': 'Codec wordt niet ondersteund voor streamen: {codec}', + 'video.err_no_mse': 'Deze browser kan geen video streamen (een iPhone heeft iOS 17.1 of nieuwer nodig)', 'video.mode_poster': 'Posters', 'video.mode_flat': 'Platte lijst', 'video.filter_all': 'All', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js index 2737532..849c632 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js @@ -288,6 +288,7 @@ export default { 'group.upload_indexing': 'indeksowanie…', 'video.err_transport': 'Transport nie jest połączony', 'video.err_mse': 'Kodek nieobsługiwany przy odtwarzaniu strumieniowym: {codec}', + 'video.err_no_mse': 'Ta przeglądarka nie obsługuje strumieniowania wideo (iPhone wymaga iOS 17.1 lub nowszego)', 'video.mode_poster': 'Plakaty', 'video.mode_flat': 'Lista płaska', 'video.filter_all': 'All', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js index c7cdf01..5672b60 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js @@ -283,6 +283,7 @@ export default { 'group.upload_indexing': 'indexando…', 'video.err_transport': 'Transporte não conectado', 'video.err_mse': 'Codec sem suporte para transmissão: {codec}', + 'video.err_no_mse': 'Este navegador não consegue transmitir vídeo (um iPhone precisa do iOS 17.1 ou mais recente)', 'video.mode_poster': 'Pôsteres', 'video.mode_flat': 'Lista simples', 'video.filter_all': 'All', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js index 06f61ff..26025ef 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js @@ -276,6 +276,7 @@ export default { 'group.upload_indexing': '建立索引中…', 'video.err_transport': '传输未连接', 'video.err_mse': '该编解码器不支持流式播放:{codec}', + 'video.err_no_mse': '此浏览器不支持视频流式播放(iPhone 需要 iOS 17.1 或更高版本)', 'video.mode_poster': '海报视图', 'video.mode_flat': '平铺列表', 'video.filter_all': 'All', diff --git a/packages/meshbay-hub/src/meshbay_hub/static/video-player.js b/packages/meshbay-hub/src/meshbay_hub/static/video-player.js index 21abe8e..5ea14ef 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/video-player.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/video-player.js @@ -1104,7 +1104,16 @@ function VideoPlayer({ entry, transportRef, gekRef, onClose, onDownload, onCopyL setAudioTrack(msg.audio_track); } - if (!window.MediaSource || !MediaSource.isTypeSupported(mime)) { + // An iPhone has no MediaSource, only ManagedMediaSource (iOS 17.1+): + // testing for the first alone refused every film there, and blamed + // the codec for it. + const MS = window.MediaSource || window.ManagedMediaSource; + if (!MS) { + setError(t('video.err_no_mse')); + setPhase('error'); + return; + } + if (!MS.isTypeSupported(mime)) { setError(t('video.err_mse', { codec: msg.codec })); setPhase('error'); return; @@ -1186,7 +1195,7 @@ function VideoPlayer({ entry, transportRef, gekRef, onClose, onDownload, onCopyL castRestartPendingRef.current = true; } - const ms = new MediaSource(); + const ms = new MS(); msRef.current = ms; if (blobUrlRef.current) URL.revokeObjectURL(blobUrlRef.current); const url = URL.createObjectURL(ms); @@ -1235,6 +1244,9 @@ function VideoPlayer({ entry, transportRef, gekRef, onClose, onDownload, onCopyL }); if (videoRef.current) { + // A ManagedMediaSource never opens on an element AirPlay could take + // over, unless it is given a second source to hand AirPlay instead. + if (MS !== window.MediaSource) videoRef.current.disableRemotePlayback = true; videoRef.current.src = url; videoRef.current.addEventListener('seeking', onSeeking); videoRef.current.addEventListener('timeupdate', pump); -- cgit v1.2.3