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 from upstream-pr/1109 into main
UwUCammie commented 2026-11-24 18:42:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by UwUCammie on 2026-11-24T18:42:37Z.


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).
    • On current main the link needs synchronization.lib (WaitOnAddress), which #877 adds. I added it only locally to build, and it is not part of this PR.
  • 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478204013 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1109). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-24T18:42:37Z. --- 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). - On current `main` the link needs `synchronization.lib` (`WaitOnAddress`), which #877 adds. I added it only locally to build, and it is not part of this PR. - 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 commented 2026-11-24 18:49:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:49:13Z.

Review: APPROVED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045330202 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1109#pullrequestreview-6045330202). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:49:13Z. **Review:** APPROVED --- 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 commented 2026-11-24 20:17:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:17:03Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143302610 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1109#issuecomment-7143302610). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:17:03Z. --- **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 commented 2026-11-24 20:33:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by UwUCammie on 2026-11-24T20:33:51Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143738153 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1109#issuecomment-7143738153). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-24T20:33:51Z. --- > [!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.
MoonEyes commented 2026-11-28 03:00:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T03:00:14Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232730361 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1109#issuecomment-7232730361). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T03:00:14Z. --- 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).
UwUCammie commented 2026-11-28 05:13:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by UwUCammie on 2026-11-28T05:13:08Z.


Rebased on current main (b1619e0a3); the branch is at 91c6768df 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 #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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7234531655 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1109#issuecomment-7234531655). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-28T05:13:08Z. --- Rebased on current `main` (b1619e0a3); the branch is at 91c6768df 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 #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.
DadaCap commented 2026-11-28 10:34:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T10:34:05Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237980464 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1109#issuecomment-7237980464). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T10:34:05Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1109
No description provided.