Skip to content

[Playback] [webOS] Resume after a pause of more than 30 s can trigger a false transcode fallback (health monitor race) #644

Closed

Description

@ophilli

Moonfin version

v2.10.0, built from source at commit e06c65e with no source changes

Platform

webOS (LG)

Platform version

webOS 11.1 (2026 model year)

TV model

OLED55C6AUA

Server

Jellyfin

Server version

12.4

Content type

Movie

Media details

Container: MKV
Resolution: 3840x2160
HDR: none (SDR, bt709)
Video: HEVC Main 10
Audio: AAC 5.1
Subs: 32 SubRip tracks (none enabled)
Bitrate: ~6.4 Mbps

Playback path

Direct Play

Symptoms

  • Black screen / endless spinner
  • Unexpected forced transcode

Steps to reproduce

  1. Play a movie that direct plays.
  2. Pause and leave the remote alone until the webOS system screensaver starts (about 3 minutes after the last key press on this TV). Moonfin's own screensaver starts first at 90 s; that one is not enough.
  3. Press a key to wake the TV.
  4. Press Play about 4.5 to 5 seconds after Moonfin gets focus back.
  5. The picture stays frozen. More presses of Play, and seeks, do nothing. Back to the title screen and then Resume starts a new Direct Play session, which works.

I have not yet hit the bug on purpose with these steps (the window is short, see the test results below). Both failures happened in normal use.

Frequency

Sometimes. See "Test results" below: 2 failures in 5 resumes after the webOS screensaver, 0 failures in 11 resumes without it.

What happens

Right after the play event, the health monitor reports the direct play stream as unhealthy and forces the transcode fallback, although the webOS pipeline had no error. From the TV's own log (wam.jsconsole), times in UTC:

06:43:54.348  html_media_element play()
06:43:54.360  starfish-media-pipeline: "playing"
06:43:54.504  [Player] Health monitor triggering transcode fallback
06:43:54.506  [Player] Playback error (no error object)
06:43:56.214  load https://<server>/videos/<id>/master.m3u8?...VideoCodec=hevc,h264&AudioCodec=aac...   (HLS, video copy)

The first failure has the same sequence (play at 06:17:19.767, fallback at 06:17:19.994).

Cause in the code

packages/app/src/services/playback.js, class PlaybackHealthMonitor:

setPaused(paused) {
	this.isPaused = paused;
	if (paused) {
		this.lastProgressTime = Date.now();
	}
}

checkHealth() {
	if (this.isPaused) {
		return true;
	}
	if (Date.now() - this.lastProgressTime > 30000) {
		this.isHealthy = false;
	}
	return this.isHealthy;
}
  • setPaused(true) sets lastProgressTime. setPaused(false) does not.
  • While paused, checkHealth() returns early and lastProgressTime stays at the time of the pause.
  • After a pause of more than 30 s, the monitor is "unhealthy" from the play event until the first timeupdate calls recordProgress().
  • If the 5 s setInterval in startHealthMonitoring ticks in that window, handleUnhealthy in WebOSPlayer.js runs. Its guard (videoRef.current?.paused) is already false, so it dispatches a synthetic error event and the player falls back.

So it is a race, which is why it is only "sometimes". In my build this is the only way the monitor can become unhealthy: recordStall() has no caller, nothing sets watchesDroppedFrames, and there were 0 and 1 waiting events before the two failures (the buffer rule needs more than 5 in 30 s). In both of my failures the tick came about 5 s after the app got focus back from the screensaver (WINDOW_FOCUSIN at 06:17:15.1 and 06:43:49.4). main at 64751df still has the same setPaused. TizenPlayer.js uses the same monitor, but its handleUnhealthy only logs, so Tizen should not be affected.

Test results (added after the first version of this report)

All times are from the TV log ([KEY_OK] button press, html_media_element play(), WINDOW_FOCUSIN), not from a stopwatch.

Resumes after the webOS system screensaver (com.webos.app.screensaver in the foreground, Moonfin gets WINDOW_FOCUSOUT), every pause about 3 minutes or longer:

WINDOW_FOCUSIN to video.play() Result
1.17 s plays
4.27 s plays
4.65 s false fallback, 0.23 s after play()
4.93 s false fallback, 0.16 s after play()
6.23 s plays

Resumes without the webOS screensaver: 11 pauses of 33 s to 172 s, all longer than 30 s, 0 failures. One of them (106 s) had Moonfin's own screensaver on screen; there the single key press woke the screensaver and resumed in the same moment.

Theory (not confirmed): the comment in handleAppHidden says "Script freezes as soon as the app is backgrounded". If the health monitor's setInterval stops while the webOS screensaver is in the foreground and starts again when Moonfin gets focus, the ticks are at about 5 s, 10 s, ... after WINDOW_FOCUSIN. Both false fallbacks were at 4.88 s and 5.08 s after focus. A normal "wake, OK, OK" sequence on the remote takes about 4.7 to 4.9 s, which puts play() just before that tick, and lastProgressTime is still the time of the pause. From the table, the window before the tick is longer than 0.23 s and shorter than about 0.7 s.

Without the screensaver the tick phase is random against the key press, so a hit needs luck (about 5 % per resume for a 0.25 s window), which fits 0 of 11.

What is still missing: a failure produced on purpose, and a test of the fix.

Suggested fix

Refresh lastProgressTime on unpause too, so a resume starts a new 30 s window:

setPaused(paused) {
	this.isPaused = paused;
	this.lastProgressTime = Date.now();
}

I have not tested this change on the TV yet.

Second problem: the fallback stream does not play

This may be a separate bug, but it is why the false fallback ends in a frozen picture and not only in a short reload.

The fallback loads the HLS master playlist (video copy to fMP4, SegmentContainer=mp4) in the native webOS player. hlsdemux2 then asks for two fragments in turn (N and N+2, for example 260 and 262) and cancels each request about 25 ms after the 200 OK. This goes on at about 20 requests per second:

gst_adaptive_demux2_stream_begin_download_uri:<hlsdemux2-0> Downloading fragment uri: .../hls1/main/262.mp4?...
HTTP_SESSION(M): > GET /videos/<id>/hls1/main/262.mp4?...
HTTP_SESSION(M): < HTTP/1.1 200 OK
downloadhelper_cancel_request: Cancelling request for URI .../hls1/main/262.mp4?...
gst_adaptive_demux2_stream_begin_download_uri:<hlsdemux2-0> Downloading fragment uri: .../hls1/main/260.mp4?...

After about one minute the pipeline fails:

[BUS]GST_MESSAGE_ERROR : GST_RESOURCE_ERROR - 3(from hlsdemux2-0), Couldn't download fragments, Fragment downloading has failed consecutive times
HandleError - error(40002) - server error:40002
HandleError - error(202) - Media Not Found

After that, each press of Play logs Uncaught (in promise) NotSupportedError: The element has no supported sources. and the player shows no error message.

On the server side every fragment request got 200 and ffmpeg (remux, -codec:v:0 copy) ran without errors. The server restarted ffmpeg at the resume position (-ss) one or two times in the first seconds of the fallback. I did not find why hlsdemux2 cancels the fragments.

Diagnostic report

The in-app diagnostic logging was off. The lines above are from /var/log/dbg-log and /var/log/legacy-log on a rooted TV. I can turn on the in-app diagnostics and reproduce if that helps.

Activity

  1. added a commit that references this issue on Nov 10, 2026
    b9783a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions