fix(host): the vsync ticker starts once; a failed ticker or audio renderer leaves no waiter #2151

Open
dazemc wants to merge 2 commits from dazemc/Longshot:fix/vsync-ticker-lock into main
Contributor

Summary

nn::vi::GetDisplayVsyncEvent registers the caller's event in a table of 8 under vsync_lock, but starts the ticker outside the lock:

if (!vsync_thread) vsync_thread = CreateThread(NULL, 0, vsync_main, NULL, 0, NULL);

Two guest threads can both see vsync_thread == NULL and each start a ticker. Every ticker runs hos_system_event_signal over the table once per period, so an auto-cleared vsync event fires twice per 16.7 ms and a waiter paced on it runs at double rate. On Linux CreateThread is pthread_create with a detached thread, and it returns after the thread may already have run — the window is real, not theoretical.

Separately, with 8 events registered the if is false, the call returns 0, and the 9th event is never in the table: its waiter blocks forever.

What changed (host/nn_vi.c): the registration and the ticker start are one section under vsync_lock; a full table returns Horizon's os::ResultOutOfResource (0x2C01, the code the host already uses for a full TLS slot table) and logs one line, instead of a silent success. A CreateThread that returns NULL — the thread limit, or no memory — is the same failure by another path: the registration is taken back, the call returns 0x2C01, and no event is left in the table with no ticker to signal it. A later call tries the ticker again. The ticker logs its start once (vi: the vsync ticker started), so a game run's log shows it.

host/nn_audio.c's OpenAudioRenderer has the same shape: it initializes the caller's auto-cleared renderer event and starts the audio thread. A NULL CreateThread now clears renderer_event, the handle and renderer_running, returns 0x2C01, logs it and leaves renderer_thread NULL so a later call retries; the event is never left registered with no thread to signal it.

Testing

Tested: at this head:

  • run_all --strict test_vsync_events test_audio_renderer_start: 2 passed, 0 failed, 0 skipped (0.3 s and 0.1 s; a passing check does not print the fixture's own lines).
  • The POSIX fixture on fix/posix-renderer-thread (a separate branch, no PR yet): PASS — a renderer thread that cannot start: reported failure, event sets 0, attempts 1.
  • The audio fixture against origin/main's host/nn_audio.c: fails on main for the reason — FAIL:56 result == 0x2C01, with a renderer thread that cannot start: result 0, handle 0x1, event 0x5000, thread (nil), attempts 1: main returns 0 and leaves the event registered.
  • The full suite at 5db210a3: 913 passed / 23 failed / 18 skipped in 815 s (the job's full output is saved at /home/daze/.local/share/longshot-dev/2151-light-job-5db210a3.log), run_all.py --strict --jobs 5 inside systemd-run --user --scope -p MemoryMax=12G -p MemorySwapMax=0 with the pinned headers. The 23 failures are the same names main fails (listed under the checklist), compared name by name; the two extra passes over a2dc5385's 911 are the new tests/test_vsync_events.py and tests/test_audio_renderer_start.py.
  • In the game at 5db210a3: queue job 2151-smoke-gpu (gpu mode, alone), Arch Linux, RTX 4070 Ti, NVIDIA 620.70.06, headless, from the repository's kokiri-start save: title to play after 8 A presses, 30 s of play, screenshot at frame 3515, then quit — run state finished, exit code 0, stop_method: quit. The log's line 224 is vi: the vsync ticker started and line 279 is audio: renderer opened; there is no could not start line and no startup hang. (The first attempt, in shared mode, was OOM-killed during first-start shader preparation with another game beside it; this run prepared them and finished.) Run folder: /home/daze/.local/share/longshot-dev/runs/control/2151-smoke-20261122-012558/.

The fixture lines the new checks assert (the branch run is above; the audio fixture's line is printed only on a failure):

a ticker that cannot start: result 0x2c01, 0 events registered
a renderer thread that cannot start: result 0x2c01, handle 0x0, event 0x0, thread (nil), attempts 1
main:  two callers at once: 2 ticker starts, 2 events registered
       FAIL: the table of 8, a 9th event: result 0
branch: two callers at once: 1 ticker start, 2 events registered
        the table of 8, a 9th event: result 0x2c01
        log: vi: GetDisplayVsyncEvent: the display's 8 vsync events are all taken
PASS

The checks that cut/read host/nn_vi.c (test_realtime_rate, test_water_substeps, test_camera_speed, test_fps_stats, test_movie_frame_count, test_scene_format) all passed in this suite.

Earlier in the game, at 5bc9f83a (before the failure-path cases and this head; the smoke under the machine lock replaces it): Arch Linux, Hyprland, RTX 4070 Ti (NVIDIA 620.70.06), a pack over 1885234b: Kokiri Forest (child), 20 s after warm-up — 1816 frames, 90.8 fps, median 11.03 ms, 0 cold frames (base: 1851 frames, 92.6 fps, 10.78 ms).

Still to test:

  • Windows: the fixture is Linux-only (pthread rwlocks), so the race itself is not exercised there (by hand).

Measurements

Nothing to measure: this fixes a race and a dropped registration, not a frame path; the in-game run above is a boot/play check and its one-run difference is not attributable.

Risks

A full vsync table, a ticker that cannot start, or an audio renderer that cannot start now reports 0x2C01 instead of 0 — a caller that ignores the Result still blocks on its unsignalled event, but the failure is visible in the result and the log, and the failed start leaves no event or handle registered behind. A later call can try again. One ticker instead of two changes only the double-signalling case. No switch; a revert is enough.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. At 5db210a3: title to play, 30 s, quit, exit 0; the log shows vi: the vsync ticker started and audio: renderer opened, no startup hang (Testing).
  • mise run test passes (any failure that also fails on main is named). At this head: 913 passed / 23 failed / 18 skipped in 815 s, tests/run_all.py --strict --jobs 5 inside systemd-run --user --scope -p MemoryMax=12G -p MemorySwapMax=0 with the pinned headers, rebased onto a2dc5385. main at a2dc5385 was 911 passed / 23 failed / 18 skipped in 635 s (--jobs 3, 8G); the two extra passes are the new tests/test_vsync_events.py and tests/test_audio_renderer_start.py. Failing names identical (23, compared name by name): nx2/test_import_windows.py, tests/test_close_waits_for_save.py, tests/test_compile_zero_byte.py, tests/test_cpm_discovery.py, tests/test_damaged_rom_files.py, tests/test_dev_packs.py, tests/test_draw_stream_visibility.py, tests/test_fs_save_commit.py, tests/test_fsr_uniform_ownership.py, tests/test_guest_copies.py, tests/test_hold_toggle.py, tests/test_lower_atomg_cas.py, tests/test_menu_i18n.py, tests/test_menu_keys.py, tests/test_menu_slider_ends.py, tests/test_mise_build.py, tests/test_pads_after_menu.py, tests/test_recording_admission.py, tests/test_sim_turf_pools.py, tests/test_sim_turf_settings.py, tests/test_switch_table.py, tests/test_tls_objects.py, tests/test_vibration_menu.py. The 23rd, tests/test_sim_turf_pools.py, is new on a2dc5385 since 9e10f6f7 and is #2174's stale check (it asserts the old zero turf floor, while #2174 made the floor the game's size); it fails identically here. Both new checks are among the 913 passes.
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here. The vsync fixture fails on main (two tickers from two callers, and the 9th event gets result 0) and passes here; the audio fixture fails on main (FAIL:56 result == 0x2C01, with result 0 and event 0x5000 still registered) and both pass at this head.
  • A check under tests/ that reads changed source is new and does not weaken an existing check.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Linux: the suite at this head built the host (pack + runtime, 913 passes). Windows: host/nn_vi.c and host/nn_audio.c compile as x86_64-w64-mingw32 COFF objects (machine 0x8664) with llvm-mingw 20261104's clang 23.1.5 under nx2/build.py's host flags, -Wno-everything included (/home/daze/.local/share/longshot-dev/2151-wincoff/). The full Windows link is not made on this PC.

Ready to merge

  • Everything in Still to test has run, its results in Tested. Windows has not: the @Beanstalk request was posted on 2026-11-22 00:02, BeanBot answered that only a member of BigBeans can start it, and no approval has come yet. The by-hand item has not run either. Ticks when that result is in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). One Tier 1 machine ran at 5bc9f83a: Arch Linux, RTX 4070 Ti, NVIDIA 620.70.06 (the earlier smoke above); at 5db210a3 it waits for the machine lock. Tier 1's Windows half has not, which is the same pending Windows item.
  • Approved in review, every comment answered. No review yet (pr status: Reviews: none); the Beanstalk approval is waiting for a BigBean.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold. The description is for head 5db210a3; the suite at this head is green apart from the 23 failures main also has, and the in-game smoke passed at this head. The CI status of 6dd681be or f00baf93 is not evidence for 5db210a3; re-confirm CI when the head reports.
## Summary `nn::vi::GetDisplayVsyncEvent` registers the caller's event in a table of 8 under `vsync_lock`, but starts the ticker **outside** the lock: ```c if (!vsync_thread) vsync_thread = CreateThread(NULL, 0, vsync_main, NULL, 0, NULL); ``` Two guest threads can both see `vsync_thread == NULL` and each start a ticker. Every ticker runs `hos_system_event_signal` over the table once per period, so an auto-cleared vsync event fires twice per 16.7 ms and a waiter paced on it runs at double rate. On Linux `CreateThread` is `pthread_create` with a detached thread, and it returns after the thread may already have run — the window is real, not theoretical. Separately, with 8 events registered the `if` is false, the call returns 0, and the 9th event is never in the table: its waiter blocks forever. What changed (`host/nn_vi.c`): the registration and the ticker start are one section under `vsync_lock`; a full table returns Horizon's `os::ResultOutOfResource` (`0x2C01`, the code the host already uses for a full TLS slot table) and logs one line, instead of a silent success. A `CreateThread` that returns NULL — the thread limit, or no memory — is the same failure by another path: the registration is taken back, the call returns `0x2C01`, and no event is left in the table with no ticker to signal it. A later call tries the ticker again. The ticker logs its start once (`vi: the vsync ticker started`), so a game run's log shows it. `host/nn_audio.c`'s `OpenAudioRenderer` has the same shape: it initializes the caller's auto-cleared renderer event and starts the audio thread. A NULL `CreateThread` now clears `renderer_event`, the handle and `renderer_running`, returns `0x2C01`, logs it and leaves `renderer_thread` NULL so a later call retries; the event is never left registered with no thread to signal it. ## Testing **Tested:** at this head: - `run_all --strict test_vsync_events test_audio_renderer_start`: **2 passed, 0 failed, 0 skipped** (0.3 s and 0.1 s; a passing check does not print the fixture's own lines). - The POSIX fixture on `fix/posix-renderer-thread` (a separate branch, no PR yet): **PASS** — `a renderer thread that cannot start: reported failure, event sets 0, attempts 1`. - The audio fixture against `origin/main`'s `host/nn_audio.c`: **fails on `main` for the reason** — `FAIL:56 result == 0x2C01`, with `a renderer thread that cannot start: result 0, handle 0x1, event 0x5000, thread (nil), attempts 1`: `main` returns 0 and leaves the event registered. - The full suite at `5db210a3`: **913 passed / 23 failed / 18 skipped in 815 s** (the job's full output is saved at `/home/daze/.local/share/longshot-dev/2151-light-job-5db210a3.log`), `run_all.py --strict --jobs 5` inside `systemd-run --user --scope -p MemoryMax=12G -p MemorySwapMax=0` with the pinned headers. The 23 failures are the same names `main` fails (listed under the checklist), compared name by name; the two extra passes over `a2dc5385`'s 911 are the new `tests/test_vsync_events.py` and `tests/test_audio_renderer_start.py`. - **In the game at `5db210a3`:** queue job `2151-smoke-gpu` (`gpu` mode, alone), Arch Linux, RTX 4070 Ti, NVIDIA 620.70.06, headless, from the repository's `kokiri-start` save: title to **play** after 8 A presses, 30 s of play, screenshot at frame 3515, then `quit` — run state `finished`, exit code 0, `stop_method: quit`. The log's line 224 is `vi: the vsync ticker started` and line 279 is `audio: renderer opened`; there is no `could not start` line and no startup hang. (The first attempt, in `shared` mode, was OOM-killed during first-start shader preparation with another game beside it; this run prepared them and finished.) Run folder: `/home/daze/.local/share/longshot-dev/runs/control/2151-smoke-20261122-012558/`. The fixture lines the new checks assert (the branch run is above; the audio fixture's line is printed only on a failure): ``` a ticker that cannot start: result 0x2c01, 0 events registered a renderer thread that cannot start: result 0x2c01, handle 0x0, event 0x0, thread (nil), attempts 1 ``` ``` main: two callers at once: 2 ticker starts, 2 events registered FAIL: the table of 8, a 9th event: result 0 branch: two callers at once: 1 ticker start, 2 events registered the table of 8, a 9th event: result 0x2c01 log: vi: GetDisplayVsyncEvent: the display's 8 vsync events are all taken PASS ``` The checks that cut/read `host/nn_vi.c` (`test_realtime_rate`, `test_water_substeps`, `test_camera_speed`, `test_fps_stats`, `test_movie_frame_count`, `test_scene_format`) all passed in this suite. Earlier in the game, at `5bc9f83a` (before the failure-path cases and this head; the smoke under the machine lock replaces it): Arch Linux, Hyprland, RTX 4070 Ti (NVIDIA 620.70.06), a pack over `1885234b`: Kokiri Forest (child), 20 s after warm-up — 1816 frames, 90.8 fps, median 11.03 ms, 0 cold frames (base: 1851 frames, 92.6 fps, 10.78 ms). **Still to test:** - Windows: the fixture is Linux-only (pthread rwlocks), so the race itself is not exercised there (by hand). ## Measurements Nothing to measure: this fixes a race and a dropped registration, not a frame path; the in-game run above is a boot/play check and its one-run difference is not attributable. ## Risks A full vsync table, a ticker that cannot start, or an audio renderer that cannot start now reports `0x2C01` instead of 0 — a caller that ignores the Result still blocks on its unsignalled event, but the failure is visible in the result and the log, and the failed start leaves no event or handle registered behind. A later call can try again. One ticker instead of two changes only the double-signalling case. No switch; a revert is enough. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. **At `5db210a3`: title to play, 30 s, quit, exit 0; the log shows `vi: the vsync ticker started` and `audio: renderer opened`, no startup hang (Testing).** - [x] `mise run test` passes (any failure that also fails on `main` is named). At this head: **913 passed / 23 failed / 18 skipped in 815 s**, `tests/run_all.py --strict --jobs 5` inside `systemd-run --user --scope -p MemoryMax=12G -p MemorySwapMax=0` with the pinned headers, rebased onto `a2dc5385`. `main` at `a2dc5385` was **911 passed / 23 failed / 18 skipped in 635 s** (`--jobs 3`, 8G); the two extra passes are the new `tests/test_vsync_events.py` and `tests/test_audio_renderer_start.py`. Failing names identical (23, compared name by name): `nx2/test_import_windows.py`, `tests/test_close_waits_for_save.py`, `tests/test_compile_zero_byte.py`, `tests/test_cpm_discovery.py`, `tests/test_damaged_rom_files.py`, `tests/test_dev_packs.py`, `tests/test_draw_stream_visibility.py`, `tests/test_fs_save_commit.py`, `tests/test_fsr_uniform_ownership.py`, `tests/test_guest_copies.py`, `tests/test_hold_toggle.py`, `tests/test_lower_atomg_cas.py`, `tests/test_menu_i18n.py`, `tests/test_menu_keys.py`, `tests/test_menu_slider_ends.py`, `tests/test_mise_build.py`, `tests/test_pads_after_menu.py`, `tests/test_recording_admission.py`, `tests/test_sim_turf_pools.py`, `tests/test_sim_turf_settings.py`, `tests/test_switch_table.py`, `tests/test_tls_objects.py`, `tests/test_vibration_menu.py`. The 23rd, `tests/test_sim_turf_pools.py`, is new on `a2dc5385` since `9e10f6f7` and is #2174's stale check (it asserts the old zero turf floor, while #2174 made the floor the game's size); it fails identically here. Both new checks are among the 913 passes. - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. **The vsync fixture fails on `main` (two tickers from two callers, and the 9th event gets result 0) and passes here; the audio fixture fails on `main` (`FAIL:56 result == 0x2C01`, with result 0 and event 0x5000 still registered) and both pass at this head.** - [x] A check under `tests/` that reads changed source is new and does not weaken an existing check. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. **Linux: the suite at this head built the host (pack + runtime, 913 passes). Windows: `host/nn_vi.c` and `host/nn_audio.c` compile as `x86_64-w64-mingw32` COFF objects (machine `0x8664`) with llvm-mingw 20261104's clang 23.1.5 under `nx2/build.py`'s host flags, `-Wno-everything` included (`/home/daze/.local/share/longshot-dev/2151-wincoff/`). The full Windows link is not made on this PC.** ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. Windows has not: the `@Beanstalk` request was posted on 2026-11-22 00:02, BeanBot answered that only a member of `BigBeans` can start it, and no approval has come yet. The by-hand item has not run either. Ticks when that result is in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). One Tier 1 machine ran at `5bc9f83a`: Arch Linux, RTX 4070 Ti, NVIDIA 620.70.06 (the earlier smoke above); at `5db210a3` it waits for the machine lock. Tier 1's Windows half has not, which is the same pending Windows item. - [ ] Approved in review, every comment answered. No review yet (`pr status`: Reviews: none); the Beanstalk approval is waiting for a BigBean. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. The description is for head `5db210a3`; the suite at this head is green apart from the 23 failures `main` also has, and the in-game smoke passed at this head. The CI status of `6dd681be` or `f00baf93` is not evidence for `5db210a3`; re-confirm CI when the head reports.
fix(host): the display's vsync ticker starts under the table's lock, and a full table is a Result
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
fa9f400442
host/nn_vi.c's GetDisplayVsyncEvent registered the caller's auto-cleared
event in vsync_events (under vsync_lock) and then started the 60 Hz ticker
outside it: `if (!vsync_thread) vsync_thread = CreateThread(...)`. Two
guest threads in the function at once both found vsync_thread NULL and
each started a ticker. Each ticker signals every registered event once a
period, so a waiter paced on one woke twice a period and ran at double
rate.

The start moves into the section that already holds the lock, after the
registration it belongs with, so a ticker started there finds the event
that started it. CreateThread on Linux is pthread_create and returns
after the thread may already have run, so nothing outside the lock can
publish "started" before a second caller looks.

The table takes 8 events and a 9th registration was silently dropped
while the call returned 0: the caller's event was never signaled and its
waiter blocked forever. It now returns 0x2C01, os::ResultOutOfResource,
as hos_thread.c answers a full TLS slot table, and logs the count. The
result is the HLE's Result, so a caller that checks it can report it; one
that ignores it still gets the log line rather than a silent hang.

tests/test_vsync_events.py cuts vsync_events, nvsync, vsync_thread and
the HLE out of host/nn_vi.c (tests/srccut.py) and builds
tests/vsync_events_test.c over them with no display: two callers at once
through a CreateThread that counts the starts and holds the first caller
inside itself, then the table filled. On main: 2 ticker starts and a 0
for the 9th registration; here: 1 start, both events registered, 0x2C01
for the 9th and the eight whole. The check also reads the source for the
start between the lock's acquire and its release.

Not run in the game: a smoke holds this PC's job queue (no game runs were
asked for). The changed code is HLE state and one thread start, and the
game-free fixture is what exercises it.
Author
Contributor

Tested in game: Kokiri Forest (child), pack over 1885234b, 20 s: 90.8 fps median 11.03 ms, 0 cold frames; boots and plays. Arch Linux/Hyprland, RTX 4070 Ti, NVIDIA 620.70.06.

Tested in game: Kokiri Forest (child), pack over 1885234b, 20 s: 90.8 fps median 11.03 ms, 0 cold frames; boots and plays. Arch Linux/Hyprland, RTX 4070 Ti, NVIDIA 620.70.06.
dazemc force-pushed fix/vsync-ticker-lock from fa9f400442
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to 936b343728
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 28s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-21 23:33:50 +00:00
Compare
Author
Contributor

Rebased onto 344deb6c (head 936b3437); #2159 also touches host/nn_vi.c and the rebase was clean, test_vsync_events still passes. The in-game run was on 1885234b.

Rebased onto 344deb6c (head 936b3437); #2159 also touches host/nn_vi.c and the rebase was clean, test_vsync_events still passes. The in-game run was on 1885234b.
Author
Contributor

@Beanstalk Windows: start the game on this branch and confirm GetDisplayVsyncEvent still runs and the game presents normally — vsync events still delivered, no stall on start. Its fixture is Linux-only, so only the start is asked.

Ready otherwise.

@Beanstalk Windows: start the game on this branch and confirm `GetDisplayVsyncEvent` still runs and the game presents normally — vsync events still delivered, no stall on start. Its fixture is Linux-only, so only the start is asked. Ready otherwise.
Member

@dazemc only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 936b343, and the PR has changed since (6dd681b), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@dazemc only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `936b343`, and the PR has changed since (`6dd681b`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
dazemc changed title from fix(host): the display's vsync ticker starts under the table's lock, and a full table is a Result to WIP: fix(host): the display's vsync ticker starts under the table's lock, and a full table is a Result 2026-11-22 01:41:52 +00:00
Author
Contributor

Back to WIP for one box: this head's merge base is 344deb6c, and main has since moved to a2dc5385 with #2171 (9e10f6f7) fixing the game-free checks (~199 test files). The suite numbers here were measured against the old main (813/116/18 there, now 911/22/18), so 'mise run test' is unticked until a rebase onto a2dc5385 and a re-run of tests/run_all.py --strict, test_vsync_events included.

The in-game smoke stands: its record (5bc9f83a, 1816 frames, 90.8 fps, 0 cold frames) matches, and the changed lines of host/nn_vi.c are identical to the head's.

The Ready to merge boxes stay unticked, each with its reason beside it: Windows (fixture is Linux-only) is with the Test Farm, waiting for a BigBean; no review yet; CI's build/test jobs are still pending.

Back to WIP for one box: this head's merge base is `344deb6c`, and `main` has since moved to `a2dc5385` with **#2171** (`9e10f6f7`) fixing the game-free checks (~199 test files). The suite numbers here were measured against the old `main` (813/116/18 there, now 911/22/18), so 'mise run test' is unticked until a rebase onto `a2dc5385` and a re-run of `tests/run_all.py --strict`, `test_vsync_events` included. The in-game smoke stands: its record (`5bc9f83a`, 1816 frames, 90.8 fps, 0 cold frames) matches, and the changed lines of `host/nn_vi.c` are identical to the head's. The Ready to merge boxes stay unticked, each with its reason beside it: Windows (fixture is Linux-only) is with the Test Farm, waiting for a BigBean; no review yet; CI's build/test jobs are still pending.
dazemc force-pushed fix/vsync-ticker-lock from 936b343728
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 28s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to 6dd681bef0
Some checks failed
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
2026-11-22 01:48:03 +00:00
Compare
Author
Contributor

Rebased onto a2dc5385: head is now 6dd681be. The rebase was clean — one commit replayed with no conflicts.

Full game-free suite, run in the same shape as a clean a2dc5385 baseline (tests/run_all.py --strict --jobs 3, systemd-run --user --scope -p MemoryMax=8G -p MemorySwapMax=0, the pinned headers):

  • clean a2dc5385: 911 passed / 23 failed / 18 skipped in 635 s
  • this head 6dd681be: 912 / 23 / 18 in 618 s

Failing names identical, compared name by name (23); the extra pass is the new tests/test_vsync_events.py. The one name new on a2dc5385 since 9e10f6f7 is tests/test_sim_turf_pools.py: #2174 changed the simulated-turf floor while that old check still asserts a zero floor, so it is stale on main and red identically here.

In-game evidence (Jev: 0.77, likely valid): the smoked 5bc9f83a record matches, the changed lines in host/nn_vi.c are identical to this head (#2159 touches the same file elsewhere), and no commit in 344deb6c..a2dc5385 touches it. No new in-game run was made.

Rebased onto `a2dc5385`: head is now `6dd681be`. The rebase was clean — one commit replayed with no conflicts. Full game-free suite, run in the same shape as a clean `a2dc5385` baseline (`tests/run_all.py --strict --jobs 3`, `systemd-run --user --scope -p MemoryMax=8G -p MemorySwapMax=0`, the pinned headers): - clean `a2dc5385`: **911 passed / 23 failed / 18 skipped in 635 s** - this head `6dd681be`: **912 / 23 / 18 in 618 s** Failing names identical, compared name by name (23); the extra pass is the new `tests/test_vsync_events.py`. The one name new on `a2dc5385` since `9e10f6f7` is `tests/test_sim_turf_pools.py`: #2174 changed the simulated-turf floor while that old check still asserts a zero floor, so it is stale on `main` and red identically here. In-game evidence (Jev: **0.77, likely valid**): the smoked `5bc9f83a` record matches, the changed lines in `host/nn_vi.c` are identical to this head (#2159 touches the same file elsewhere), and no commit in `344deb6c..a2dc5385` touches it. No new in-game run was made.
dazemc changed title from WIP: fix(host): the display's vsync ticker starts under the table's lock, and a full table is a Result to fix(host): the display's vsync ticker starts under the table's lock, and a full table is a Result 2026-11-22 02:58:36 +00:00
Author
Contributor

@Beanstalk Windows: start the game on this branch and confirm GetDisplayVsyncEvent still runs and the game presents normally — vsync events still delivered, no stall on start. Its fixture is Linux-only, so only the start is asked.

Head: 6dd681be (rebased onto a2dc5385).

@Beanstalk Windows: start the game on this branch and confirm `GetDisplayVsyncEvent` still runs and the game presents normally — vsync events still delivered, no stall on start. Its fixture is Linux-only, so only the start is asked. Head: `6dd681be` (rebased onto `a2dc5385`).
Member

@dazemc only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 6dd681b, and the PR has changed since (9cd4714), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@dazemc only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `6dd681b`, and the PR has changed since (`9cd4714`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
fix(host): a vsync ticker that cannot start leaves no event registered
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Description follows the template (pull_request_target) Successful in 9s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
9cd4714fde
GetDisplayVsyncEvent registered the event and then started the ticker.
CreateThread can return NULL (the thread limit, or no memory), leaving
the event in the table with no thread to signal it: its waiter blocks
forever, the same failure as a full table through another path.

Take the registration back, answer os::ResultOutOfResource (0x2C01), and
log it; a later call can try the ticker again.

tests/vsync_events_test.c gets a CreateThread that fails and asserts the
event is not left registered, with the result a failure.
dazemc force-pushed fix/vsync-ticker-lock from 9cd4714fde
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Description follows the template (pull_request_target) Successful in 9s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to f00baf93a7
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Description follows the template (pull_request_target) Successful in 6s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
2026-11-22 07:03:21 +00:00
Compare
Author
Contributor

Description updated for head f00baf93: the CreateThread NULL path now covers the vsync ticker and nn_audio.c's renderer (event/handle cleared, 0x2C01, retry), with tests/audio_renderer_start_test.c + test_vsync_events' new case; the vsync fixture's InterlockedDecrement stub is in this head. The suite numbers at a2dc5385/6dd681be are not evidence for f00baf93: the targeted fixtures and suite at f00baf93 are queued, results to follow.

Description updated for head f00baf93: the CreateThread NULL path now covers the vsync ticker and nn_audio.c's renderer (event/handle cleared, 0x2C01, retry), with tests/audio_renderer_start_test.c + test_vsync_events' new case; the vsync fixture's InterlockedDecrement stub is in this head. The suite numbers at a2dc5385/6dd681be are not evidence for f00baf93: the targeted fixtures and suite at f00baf93 are queued, results to follow.
dazemc changed title from fix(host): the display's vsync ticker starts under the table's lock, and a full table is a Result to WIP: fix(host): the display's vsync ticker starts under the table's lock, and a full table is a Result 2026-11-22 07:24:10 +00:00
dazemc force-pushed fix/vsync-ticker-lock from f00baf93a7
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Description follows the template (pull_request_target) Successful in 6s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to 5db210a3e1
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
beanstalk/approval changed since the request: ask again
PR description / Description follows the template (pull_request_target) Successful in 4s
2026-11-22 07:30:08 +00:00
Compare
Author
Contributor

Marked WIP and unticked the boxes the new head invalidates (in-game test, suite, fix-fails-on-main: reasons beside each). Head is now 5db210a3: the ticker logs its start once ("vi: the vsync ticker started") so the in-game smoke can read it out of the log; that is the only change since f00baf93. One queued job will run, in order: the two branch fixtures, the POSIX fixture (separate branch), the audio fixture against origin/main (it must fail there for the reason), the full suite at this head (jobs 5, MemoryMax=12G), then dev.py rt and a shared-mode game smoke (kokiri-start save, title to play, 30 s, quit) checking the ticker line, "audio: renderer opened" and no startup hang. Boxes stay unticked until that output is in Tested.

Marked WIP and unticked the boxes the new head invalidates (in-game test, suite, fix-fails-on-main: reasons beside each). Head is now 5db210a3: the ticker logs its start once ("vi: the vsync ticker started") so the in-game smoke can read it out of the log; that is the only change since f00baf93. One queued job will run, in order: the two branch fixtures, the POSIX fixture (separate branch), the audio fixture against origin/main (it must fail there for the reason), the full suite at this head (jobs 5, MemoryMax=12G), then dev.py rt and a shared-mode game smoke (kokiri-start save, title to play, 30 s, quit) checking the ticker line, "audio: renderer opened" and no startup hang. Boxes stay unticked until that output is in Tested.
Author
Contributor

Added the host-build checklist row the diff suggests (host/nn_audio.c and host/nn_vi.c): unticked until the queued Linux build and the Windows item land. No code change in this update.

Added the host-build checklist row the diff suggests (host/nn_audio.c and host/nn_vi.c): unticked until the queued Linux build and the Windows item land. No code change in this update.
dazemc changed title from WIP: fix(host): the display's vsync ticker starts under the table's lock, and a full table is a Result to WIP: fix(host): the vsync ticker starts once; a failed ticker or audio renderer leaves no waiter 2026-11-22 08:49:13 +00:00
Author
Contributor

Re-queued without blocking timing runs: the POSIX fixture, the audio fixture against origin/main and the full suite at 5db210a3 now run as one light job in the job queue (dev.py queue run --mode light), outside the machine lock; only dev.py rt and the 30 s game smoke take the lock, after the timing jobs ahead of them (#2154's keys, finalized-2). The description's "queued" wording is corrected accordingly (the lock poller is not a queue job). Title widened to name the nn_audio.c half. Already green at this head: run_all --strict test_vsync_events test_audio_renderer_start, 2 passed.

Re-queued without blocking timing runs: the POSIX fixture, the audio fixture against origin/main and the full suite at 5db210a3 now run as one light job in the job queue (dev.py queue run --mode light), outside the machine lock; only dev.py rt and the 30 s game smoke take the lock, after the timing jobs ahead of them (#2154's keys, finalized-2). The description's "queued" wording is corrected accordingly (the lock poller is not a queue job). Title widened to name the nn_audio.c half. Already green at this head: run_all --strict test_vsync_events test_audio_renderer_start, 2 passed.
Author
Contributor

Results at 5db210a3, light job outside the machine lock: POSIX fixture PASS (reported failure, event not set, one attempt); audio fixture against origin/main fails for the reason (FAIL:56 result == 0x2C01, result 0, event 0x5000 still registered) and passes here; full suite 913 passed / 23 failed / 18 skipped in 815 s with --jobs 5 under MemoryMax=12G, the 23 names identical to main's. Ticked the suite and fix-fails-on-main boxes from that output. Still unticked: in-game smoke (running under the machine lock after the timing jobs, including #2154) and the host-build box's Windows half. Title and wording already correct.

Results at 5db210a3, light job outside the machine lock: POSIX fixture PASS (reported failure, event not set, one attempt); audio fixture against origin/main fails for the reason (FAIL:56 result == 0x2C01, result 0, event 0x5000 still registered) and passes here; full suite 913 passed / 23 failed / 18 skipped in 815 s with --jobs 5 under MemoryMax=12G, the 23 names identical to main's. Ticked the suite and fix-fails-on-main boxes from that output. Still unticked: in-game smoke (running under the machine lock after the timing jobs, including #2154) and the host-build box's Windows half. Title and wording already correct.
Author
Contributor

The first in-game smoke at 5db210a3 did not reach the title: the system OOM killer killed the shared queue job during first-start shader preparation (start-up 36499/38809, 38809 programs, 6.2G peak + 3.8G swap) while another shared game ran. That is machine pressure, not a code result; the run's log shows the host up to device init only, so nothing is ticked. Retrying alone in the queue's gpu mode with a 900 s readiness timeout, under the machine lock after the timing jobs (#2154 is ahead).

The first in-game smoke at 5db210a3 did not reach the title: the system OOM killer killed the shared queue job during first-start shader preparation (start-up 36499/38809, 38809 programs, 6.2G peak + 3.8G swap) while another shared game ran. That is machine pressure, not a code result; the run's log shows the host up to device init only, so nothing is ticked. Retrying alone in the queue's gpu mode with a 900 s readiness timeout, under the machine lock after the timing jobs (#2154 is ahead).
Author
Contributor

Correction: the smoke retry is now a real queue ticket, not a lock poller — job 2151-smoke-gpu, mode gpu (no other game beside it), readiness timeout 900 s, waiting for the GPU behind #2154's shared probe; queue status shows it. The 913/23/18 suite output is saved at /home/daze/.local/share/longshot-dev/2151-light-job-5db210a3.log and the body names it. The Windows COFF check for host/nn_vi.c and host/nn_audio.c is job 2151-wincoff (light), waiting on the queue's memory admission; the host-build box stays unticked until it compiles.

Correction: the smoke retry is now a real queue ticket, not a lock poller — job 2151-smoke-gpu, mode gpu (no other game beside it), readiness timeout 900 s, waiting for the GPU behind #2154's shared probe; queue status shows it. The 913/23/18 suite output is saved at /home/daze/.local/share/longshot-dev/2151-light-job-5db210a3.log and the body names it. The Windows COFF check for host/nn_vi.c and host/nn_audio.c is job 2151-wincoff (light), waiting on the queue's memory admission; the host-build box stays unticked until it compiles.
Author
Contributor

Windows half of the host-build box done: host/nn_vi.c and host/nn_audio.c compile as x86_64-w64-mingw32 COFF objects (machine 0x8664, 33 KB and 170 KB) with llvm-mingw 20261104's clang 23.1.5. The first attempt used #2180's shortened flag list and failed on nn_vi.c's early rx_option call (implicit declaration); the real host flags from nx2/build.py add -Wno-everything, and both compile with them. Objects at /home/daze/.local/share/longshot-dev/2151-wincoff/. Box ticked. Smoke 2151-smoke-gpu still waits for the GPU.

Windows half of the host-build box done: host/nn_vi.c and host/nn_audio.c compile as x86_64-w64-mingw32 COFF objects (machine 0x8664, 33 KB and 170 KB) with llvm-mingw 20261104's clang 23.1.5. The first attempt used #2180's shortened flag list and failed on nn_vi.c's early rx_option call (implicit declaration); the real host flags from nx2/build.py add -Wno-everything, and both compile with them. Objects at /home/daze/.local/share/longshot-dev/2151-wincoff/. Box ticked. Smoke 2151-smoke-gpu still waits for the GPU.
Author
Contributor

In-game smoke passed at 5db210a3 (job 2151-smoke-gpu, gpu mode alone): title to play after 8 presses, 30 s of play, screenshot at frame 3515, quit with exit 0. Log line 224 'vi: the vsync ticker started', line 279 'audio: renderer opened'; no could-not-start line and no startup hang. Ticked the in-game box; the earlier OOM was the shared-mode first-start shader preparation with another game beside it, not the change. With the suite, the fixtures and the Windows COFF objects, every Ready-for-review and When-it-applies box is ticked.

In-game smoke passed at 5db210a3 (job 2151-smoke-gpu, gpu mode alone): title to play after 8 presses, 30 s of play, screenshot at frame 3515, quit with exit 0. Log line 224 'vi: the vsync ticker started', line 279 'audio: renderer opened'; no could-not-start line and no startup hang. Ticked the in-game box; the earlier OOM was the shared-mode first-start shader preparation with another game beside it, not the change. With the suite, the fixtures and the Windows COFF objects, every Ready-for-review and When-it-applies box is ticked.
dazemc changed title from WIP: fix(host): the vsync ticker starts once; a failed ticker or audio renderer leaves no waiter to fix(host): the vsync ticker starts once; a failed ticker or audio renderer leaves no waiter 2026-11-22 09:28:36 +00:00
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
beanstalk/approval changed since the request: ask again
PR description / Description follows the template (pull_request_target) Successful in 4s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/vsync-ticker-lock:dazemc-fix/vsync-ticker-lock'
git switch 'dazemc-fix/vsync-ticker-lock'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2151
No description provided.