Skip to content

Offer to free the video decoder when Steam holds it - #94

Merged
seaweeduk merged 2 commits into
masterfrom
fix/free-decoder-from-steam
Nov 22, 2026
Merged

seaweeduk merged 2 commits into
masterfrom
fix/free-decoder-from-steam

Conversation

@seaweeduk

@seaweeduk seaweeduk commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

On the Steam Frame, Steam's interface can keep sessions open on the hardware video decoder and never close them. An 8K HEVC video that needs the whole decoder then fails to start with "Can't play this video", and so far the only fix was restarting Steam or the headset.

Now, when the decoder refuses a video and Steam is holding it, the app asks whether to free it. Freeing it ends Steam's background process that holds the decoder, which Steam restarts by itself. The video then opens again where it was. Always free does that now and from then on without asking; Settings → Playback switches it off again.

Steam holds the decoder If it is still busy
The dialog: Steam is using the video decoder, Cancel, Always free or Free and play Notice: The video decoder is busy. Restart Steam or the headset.

The switch in Settings → Playback (Steam Frame only):

Always free the video decoder, off

Before, the same case only showed:

Notice: Can't play this video. Try another file.

flowchart LR
  A["Decoder refuses the video"] --> B{"Who holds it?<br/>(off the render thread)"}
  B -- "Steam's web helper" --> C["Ask: Cancel / Always free / Free and play<br/>(not asked once Always free)"]
  B -- "something else" --> E["Decoder busy:<br/>restart Steam or the headset"]
  B -- "nothing" --> F["Can't play this video"]
  C -- "Free" --> D["End the helper,<br/>wait until it lets go,<br/>reopen at the same position"]
  D -- "refused again" --> E
Loading
  • src/decoder_holders.cpp finds this user's processes holding the decoder. Inside the Steam Runtime's container, other processes' open files can't be followed, so Steam's web helper is recognised by Chromium's V4L2 decoding thread instead. Freeing sends SIGTERM. After 2 s it sends SIGKILL only to current decoder holders whose PIDs were in that first set.
  • The choice is saved as free_decoder_from_steam in settings.conf (off by default).
  • The video is opened again once per refusal. If it fails again, the notice says the decoder is busy instead of asking again.
  • Once the app has identified a decoder refusal, it skips the Stash stream fallback for that failure. The stream is the same video and failed the same way.
  • The bundled FFmpeg opens the decoder close-on-exec (avpriv_open), so a process the app starts can't keep a decoder session alive.
  • The new text is translated into all six languages.

Known and left as is

  • Stash can still fall back to the stream if file failure arrives before the decoder refusal is recorded.
  • The recovery check matches PIDs over a wait of about three seconds. It skips helpers with new PIDs but does not guard against PID reuse in that window.

Important

AI disclosure

Model Variant Role
anthropic/claude-opus-5-5 high Investigation, implementation
openai/gpt-6.2-astra high Design second opinion, code review

Agent harness OpenCode 2.3.2

@seaweeduk seaweeduk added the fix Bug fix (release notes: Fixes) label Nov 22, 2026
@opencode-agent

Copy link
Copy Markdown
  1. Medium — Clear the retry marker once playback succeeds (src/main.cpp:4211–4213). After Free and play succeeds, r.retry still identifies that opening for the rest of playback. On the Frame, putting the headset to sleep and waking it closes and reopens the video track without incrementing loadCount(). If Steam has acquired decoder sessions again, the new refusal goes straight to StillBusy: the app tells the user to restart Steam without checking the holders, even with Always free enabled. Clear r.retry when player.takeOpened() confirms that the retried opening succeeded. An immediate second refusal will still produce the busy notice.

  2. Low — A hidden dialog can suppress the recovery prompt (src/main.cpp:4234–4241). Closing the menu with the controller hides the panel but leaves menu.dialogOpen() true until the menu is reopened. For example, dismiss What’s new with the menu button, then use Next video to open a video that Steam’s decoder sessions block. The user sees “Restart Steam or the headset” instead of the recovery offer because the invisible dialog keeps r.ask waiting. Only defer to another dialog when its panel is open; when opening a closed panel for recovery, use the normal showMainPage() behavior to clear the hidden dialog before showing the prompt.

github run

@seaweeduk
seaweeduk force-pushed the fix/free-decoder-from-steam branch from d3369f0 to 22680ca Compare November 22, 2026 20:14
@seaweeduk

Copy link
Copy Markdown
Owner Author

/oc Please re-review the changes since the first review.

  1. Retry marker kept after a successful Free and play: fixed in 22680ca. Right after player.takeOpened(), the opening that was retried clears decoderRescue.retry once it has played. A later refusal in that opening (after a sleep) therefore checks the holders again and asks, or frees with Always free. An immediate second refusal of the retry still gives the busy notice.
  2. A hidden dialog holding back the question: fixed in 22680ca. The question now only waits for another dialog while the panel is open (!(panel.open && menu.dialogOpen())). When it opens a closed panel to ask, it calls menu.showMainPage() first, which clears the hidden dialog as the menu button does.

The refactor layers above (#96–#101) carry the same two changes where the code moved.

@opencode-agent

Copy link
Copy Markdown

Both findings from the first review are resolved in 22680ca7. I found no new issues in the follow-up diff for #94.

  • Retry after sleep: takeOpened() confirms the retried video started before the retry marker is cleared. An immediate second refusal still shows the busy notice. A refusal after sleep checks the holders again and honors Always free.
  • Hidden dialog: A dialog in a closed panel no longer blocks the recovery question. Reopening the panel calls showMainPage() to clear the old dialog before asking. A visible dialog or first-run setup still takes precedence.

Verified by tracing the playback and menu paths in code; I did not test on a headset.

github run

@seaweeduk
seaweeduk force-pushed the fix/free-decoder-from-steam branch from 22680ca to 0c86ba5 Compare November 22, 2026 20:58
@seaweeduk
seaweeduk changed the base branch from feature/controls to master November 22, 2026 20:58
@seaweeduk
seaweeduk merged commit f05cd9a into master Nov 22, 2026
@seaweeduk
seaweeduk deleted the fix/free-decoder-from-steam branch November 22, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix (release notes: Fixes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant