Skip to content

runtime: warn at start when the host has no default audio output (RT-NO-AUDIO-ENDPOINT-DEADLOCK) - #1109

Closed
UwUCammie wants to merge 1 commit into
ProjectLeonida:mainfrom
UwUCammie:uwu/no-audio-endpoint-warning
Closed

UwUCammie wants to merge 1 commit into
ProjectLeonida:mainfrom
UwUCammie:uwu/no-audio-endpoint-warning

Conversation

@UwUCammie

@UwUCammie UwUCammie commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Item: RT-NO-AUDIO-ENDPOINT-DEADLOCK (claimed in #14)

What

With no default audio render endpoint, the retail title does not fail at once. It stops after the first-run screens (account, privacy and terms) on a dark loading screen that keeps being drawn. Nothing crashes, and nothing in the startup or D3D12 trace points at audio. A muted Wine run is the usual way to get there: winealsa.drv and winepulse.drv off, or no /dev/snd and no sound server sockets.

This PR does two things:

  • Startup warning. runtime/src/audio_endpoint_probe.h asks the host once at start, on its own thread and in its own COM apartment, for IMMDeviceEnumerator::GetDefaultAudioEndpoint(eRender, eConsole). When there is none, main.cpp prints an [rt] audio: line that points at the docs.
  • Docs. docs/boot.md §6 records the measured chain and a silent workaround for muted runs: ALSA's null plugin through ALSA_CONFIG_PATH.

The measured chain

Measured on my own copy of the Xbox package 1.0.2.1, using breakpoint hit counts and thread dumps (LEONIDA_BREAK, LEONIDA_THREAD_DUMP):

  1. The title asks for the default render endpoint once. When there is none, it skips its audio device setup, which activates IAudioClient and ISpatialAudioClient. The audio object's output list stays empty.
  2. The per-frame audio update takes that object's lock, finds no outputs, and returns early without releasing the lock. It runs on a pool worker, which then goes back to waiting for jobs while still owning the lock.
  3. The frame thread blocks on the same lock. The frame tick, which advances the frame counter and wakes threads parked on it, ran exactly once in the whole run.
  4. The main thread parks in a startup step until the frame counter moves on, so it is never woken. Every streaming update it drives stops too. A later synchronous streaming request then spins for ever.

With an output device, the same build gets past this point. The audio setup runs, the early return is never taken, and the frame tick keeps running.

The RVAs are in the docs. No game data, code bytes or disassembly are in the PR.

Tested

  • Built gta6rt with clang-cl and xwin on Linux (CachyOS).
  • Ran it under Wine 11.22 on an RX 7900 XT (RADV, Mesa 26.3.1):
    • Muted (no output device): the warning is printed with GetDefaultAudioEndpoint returning 0x80070490.
    • ALSA null device from the docs: no warning, and startup is otherwise identical.
  • On my integration branch, with the null device, the boot gets past the loading-screen stall to a later, unrelated stop.
  • python -I scripts/check_no_game_data.py on the changed files passes, and so does tests/test_text_write_line_endings.py.

AI-assisted: yes. The investigation, the code and the docs were written by an AI coding assistant working on this account; the tests above are the ones it ran.

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified. Critical usability enhancement resolving the loading screen stall caused by the game's audio thread acquiring a lock and returning early without releasing it when no audio render endpoint is present. Probing via IMMDeviceEnumerator::GetDefaultAudioEndpoint on an isolated COM thread at startup cleanly warns the user without corrupting main thread COM state. Documentation and ALSA null workaround in docs/boot.md are excellent. 100% clean-room compliant.

@Deedlyy

Deedlyy commented Nov 24, 2026

Copy link
Copy Markdown

Recommendation: [WAIT]

Reasoning: Adds a startup probe (own thread and COM apartment) that warns when the host has no default audio render endpoint, plus a well-written docs/boot.md section explaining the measured deadlock and an ALSA null-plugin workaround. The idea is useful, but the probe runs on every start and has no test or independent run. Before merging, someone should confirm on Windows and Wine that it doesn't delay or block startup when an endpoint exists and that it warns correctly when none does. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main.

Impact level: 3/10

@UwUCammie

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of UwUCammie

Measured both cases under Wine 11.22 (RX 7900 XT, same build as the PR plus a temporary timing print around the probe; not committed):

Host Probe time Result Warning
ALSA null device (endpoint present) 8 ms, 10 ms GetDefaultAudioEndpoint S_OK none
winealsa/winepulse disabled, no /dev/snd (no endpoint) 12 ms, 19 ms 0x80070490 (E_NOTFOUND) printed once

The probe also has a 5 s ceiling: if the audio service never answers, the result is unknown and nothing is printed, so it cannot block startup. Not yet run on Windows; that confirmation still needs someone with a Windows host.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
milk4sale pushed a commit to milk4sale/leonida that referenced this pull request Nov 27, 2026
…aging-collisions

fix(pipeline): retry collisions when creating cache staging files
@MoonEyes

Copy link
Copy Markdown
Collaborator

Hi @UwUCammie, thanks for this pull request. It currently conflicts with main (conflicting file(s): docs/README.md, runtime/src/main.cpp), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

…NO-AUDIO-ENDPOINT-DEADLOCK)

With no default audio render endpoint the retail title skips its audio
device setup and later stops on a loading screen after the first-run
screens: its per-frame audio update returns early while holding a lock,
the frame thread waits on that lock for good, the frame counter stops and
the main thread waits for frames that never come. Nothing crashes, so the
cause is hard to find from the logs.

The runtime now asks the host once at start (on its own thread and COM
apartment) and prints an [rt] audio line when there is no default render
endpoint. docs/boot.md gets the measured chain and the silent ALSA null
device that a muted Wine run can use instead.
@UwUCammie
UwUCammie force-pushed the uwu/no-audio-endpoint-warning branch from 40ab6cb to 91c6768 Compare November 28, 2026 05:12
@UwUCammie

Copy link
Copy Markdown
Contributor Author

Rebased on current main (b1619e0); the branch is at 91c6768 and merges cleanly again.

The two conflicts were only in context: the boot.md row in docs/README.md sits next to the new first_run_ui.md row, and the include in runtime/src/main.cpp now comes after the watchdog and peek helpers. The change itself is the same four files as before.

Checked after the rebase:

  • check_no_game_data.py on the four files, and the docs tests (test_docs_table_rows, test_docs_links, test_docs_encoding): pass.
  • runtime/src/main.cpp compiles with clang-cl against the xwin SDK using the gta6rt target's definitions (syntax only, I did not link the runtime this time).
  • test_docs_env_vars fails on main itself right now, with or without this branch: LEONIDA_CLWB_PATCH (runtime/src/cpu_emulation.h:366, from cpu_emulation: CLWB rewrite in place without the race between threads (follow-up of #1472) #2559) is not named in any .md file. Not something this pull request touches.

The Wine timings from my earlier comment were taken on the old base and not repeated. Still not run on a Windows host.

@github-actions github-actions Bot added needs rebase Conflicts with the base branch: rebase it on main and removed needs rebase Conflicts with the base branch: rebase it on main labels Nov 28, 2026
@DadaCap

DadaCap commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the contribution! This PR was reviewed by the maintainers and is being closed as part of a large batch of closures.

Reason: superseded by main.

If this looks like a mistake, mention @DadaCap here at any time and it will be looked at again.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

@DadaCap DadaCap closed this Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants