watchdog: tell the user when a video never starts, and offer transcode

Some files never produce a picture on some machines. The Quest decodes the
8K HEVC Main 10 files fine; a Windows desktop browser claims HEVC Main 10 up to
level 6.1 via canPlayType() (Jellyfin Web builds its device profile from that,
browserDeviceProfile.js) so the server picks Direct Play, and the desktop GPU
cannot actually decode it. Result: black screen and a spinner.

The user-visible symptom is worse than it sounds: Jellyfin Web creates the whole
player UI only after 'playbackstart', which never fires, so the OSD -- including
the quality menu -- is never built. There is literally nothing to click to lower
the bitrate. Load order, from the source:

  HtmlVideoPlayer.play()            htmlVideoPlayer/plugin.js:502
    createMediaElement()            :1802  spinner + <div.videoPlayerContainer>
                                           + <video>, inserted with no src yet
    setCurrentSrc()                 :593   elem.src = url
      -> loadedmetadata -> canplay -> play -> 'playbackstart'
        -> OSD controller (apps/legacy/controllers/playback/video/index.js:591)

So 40-watchdog.js watches for exactly the pre-OSD state: a .videoPlayerContainer
whose <video> still has videoWidth === 0. It fires immediately on a media error,
or after 15s (45s when the src is already an HLS transcode, where the server has
to produce segments first). It stands down the moment there is a picture, and
never runs during a VR session.

The panel names the format (fetched from the Jellyfin API), explains the cause,
and offers 20/8/3 Mbps plus "keep waiting". A choice writes the same localStorage
keys Jellyfin's own menu writes and reloads: window.playbackManager is not
reachable from injected script (verified: undefined; window.Emby only has Page),
so the settings path is the only option. Note the upstream key really is
'enableautobitratebitrate-...' with "bitrate" twice; reproduced deliberately.
A 120s cooldown in sessionStorage stops it nagging a slow-but-working playback.

Verified against a local harness (3 cases, all passing): healthy playback ->
never arms; media error -> immediate; hung stream -> ~16.4s; dismiss -> hides and
persists the cooldown, and stayed hidden 20s past the threshold; bitrate choice
-> writes maxbitrate-Video-true/false=20000000 and
enableautobitratebitrate-Video-true/false=false, then reloads.
This commit is contained in:
2026-10-18 00:27:53 +08:00
parent 51ab1a4b48
commit d0fe04bf25
4 changed files with 727 additions and 2 deletions
+3
View File
@@ -1943,6 +1943,9 @@
try { if (NS.Subtitles && NS.Subtitles.init) NS.Subtitles.init(); } catch (e) { NS.recordError('Subtitles.init', e); }
try { if (NS.Controls && NS.Controls.init) NS.Controls.init(); } catch (e) { NS.recordError('Controls.init', e); }
try { if (NS.Hands && NS.Hands.init) NS.Hands.init(); } catch (e) { NS.recordError('Hands.init', e); }
// Watches for "the player never produced a picture" and offers the only fix
// that helps (let the server transcode). See 40-watchdog.js.
try { if (NS.Watchdog && NS.Watchdog.init) NS.Watchdog.init(); } catch (e) { NS.recordError('Watchdog.init', e); }
scan();
new MutationObserver(scan).observe(document.documentElement, { childList: true, subtree: true });