D3D12-GPU-REPLAY-WORKER-DROP-AND-PACE: close Worker event handle on drop and guard pace duration #2994

Open
bobcatchris wants to merge 1 commit from upstream-pr/2994 into main
bobcatchris commented 2026-12-01 22:44:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T22:44:33Z.


Addresses claim in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7327924046.

Changes

  1. Close Worker event handle on drop (\d3d12/crates/leonida-gpu/src/replay/gpu.rs):
    • Implement \Drop\ for \Worker\ to call \CloseHandle(self.event)\ when valid and reset \self.event, eliminating an OS event handle leak on every \Worker\ replacement in \Player::upload\ / batch copy and on \Player/\Capture\ drop.
  2. Guard replay \pace\ float-to-\Duration\ conversion (\d3d12/crates/leonida-gpu/src/replay/play.rs):
    • Extract \pace_until(now, pace_ms)\ using finite checks, \Duration::try_from_secs_f64(pace_ms / 1e3), and \Instant::checked_add, preventing panics on \NaN, \inf, or overflowing finite millisecond values.

Verification

  • Red -> Green:
    • Stubbing \CloseHandle\ in \Worker::drop\ fails
      eplay::gpu::tests::worker_drop_closes_event_handle\ (exit 101); restoring \CloseHandle\ passes.
    • Using unguarded \Duration::from_secs_f64\ in \pace_until\ fails
      eplay::play::tests::pace_until_rejects_non_finite_and_overflowing_values\ (exit 101); guarded conversion passes.
  • \cargo test --locked -p leonida-gpu --lib --features diagnostics -- replay::: 26 passed, 0 failed.
  • \cargo test --locked -p leonida-gpu --features diagnostics --test replay: 1 passed, 0 failed (includes \pace: f64::INFINITY\ on AMD Radeon RX 7900 XTX).
  • \python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0.
  • \python -I scripts/check_no_game_data.py\ on changed files: exit 0.
  • Independent read-only code review: approved.

AI-assisted: Gemini 4 Neon (including an independent read-only review pass, APPROVE).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5595978892 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T22:44:33Z. --- Addresses claim in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7327924046. ### Changes 1. **Close Worker event handle on drop** (\d3d12/crates/leonida-gpu/src/replay/gpu.rs\): - Implement \Drop\ for \Worker\ to call \CloseHandle(self.event)\ when valid and reset \self.event\, eliminating an OS event handle leak on every \Worker\ replacement in \Player::upload\ / batch copy and on \Player\/\Capture\ drop. 2. **Guard replay \pace\ float-to-\Duration\ conversion** (\d3d12/crates/leonida-gpu/src/replay/play.rs\): - Extract \pace_until(now, pace_ms)\ using finite checks, \Duration::try_from_secs_f64(pace_ms / 1e3)\, and \Instant::checked_add\, preventing panics on \NaN\, \inf\, or overflowing finite millisecond values. ### Verification - **Red -> Green**: - Stubbing \CloseHandle\ in \Worker::drop\ fails \ eplay::gpu::tests::worker_drop_closes_event_handle\ (exit 101); restoring \CloseHandle\ passes. - Using unguarded \Duration::from_secs_f64\ in \pace_until\ fails \ eplay::play::tests::pace_until_rejects_non_finite_and_overflowing_values\ (exit 101); guarded conversion passes. - \cargo test --locked -p leonida-gpu --lib --features diagnostics -- replay::\: 26 passed, 0 failed. - \cargo test --locked -p leonida-gpu --features diagnostics --test replay\: 1 passed, 0 failed (includes \pace: f64::INFINITY\ on AMD Radeon RX 7900 XTX). - \python -I tools/d3d12_switches.py --check d3d12/docs/switches.md\: exit 0. - \python -I scripts/check_no_game_data.py\ on changed files: exit 0. - Independent read-only code review: approved. AI-assisted: Gemini 4 Neon (including an independent read-only review pass, APPROVE).
merzleckeier commented 2026-12-01 23:00:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T23:00:03Z.


All 26 replay unit tests passed on NVIDIA and RADV through Wine.

I built fccce448 on main 002bd88f8, with #2975 and #2995 layered in. The replay source files match the isolated #2994 integration. A Windows MSVC-target leonida-gpu libtest build with --features diagnostics ran replay:: --nocapture --test-threads=1 on the RTX 4070 SUPER (620.73.4) and Radeon Raphael (RADV 26.3.1). On both GPUs it passed 26/26, including the worker event-handle child on a live D3D12 device and the pacing boundary unit test. Environment: Wine 11.22, VKD3D-Proton 3.1.0, one Vulkan ICD visible per run.

I separately built --features diagnostics --test replay and ran --exact a_frame_is_recorded_and_replayed on both GPUs, using the same setup and a #2975-only build as control. Both trees on both GPUs hit the same Wine read fault after the synthetic scene was created under recording, before the new infinity playback step. All four integration runs exited 5. The paired control shows that this local Wine run stops at the same point without #2994. Synthetic capture only. MEASURED, AI-assisted with OpenAI Codex and independent raw-log verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328622293 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994#issuecomment-7328622293). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T23:00:03Z. --- All 26 replay unit tests passed on NVIDIA and RADV through Wine. I built `fccce448` on main `002bd88f8`, with #2975 and #2995 layered in. The replay source files match the isolated #2994 integration. A Windows MSVC-target `leonida-gpu` libtest build with `--features diagnostics` ran `replay:: --nocapture --test-threads=1` on the RTX 4070 SUPER (620.73.4) and Radeon Raphael (RADV 26.3.1). On both GPUs it passed 26/26, including the worker event-handle child on a live D3D12 device and the pacing boundary unit test. Environment: Wine 11.22, VKD3D-Proton 3.1.0, one Vulkan ICD visible per run. I separately built `--features diagnostics --test replay` and ran `--exact a_frame_is_recorded_and_replayed` on both GPUs, using the same setup and a #2975-only build as control. Both trees on both GPUs hit the same Wine read fault after the synthetic scene was created under recording, before the new infinity playback step. All four integration runs exited 5. The paired control shows that this local Wine run stops at the same point without #2994. Synthetic capture only. MEASURED, AI-assisted with OpenAI Codex and independent raw-log verification.
andrew-ai commented 2026-12-01 23:16:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T23:16:39Z.


The unmodified a_frame_is_recorded_and_replayed integration test at fccce4485 passed on native Windows. It recorded the synthetic scene (3 submissions, 4 lists, 18 resources, 6 pipelines), completed the added player.run with pace=f64::INFINITY, and reached the final replay assertions. The reported final picture hash matched the recording, 4aaec8b6026567d0. One test passed in 1.42 s.

Command: cargo test --locked --profile diag --features diagnostics -p leonida-gpu --test replay -- --exact a_frame_is_recorded_and_replayed --nocapture

This supplies a native result for the integration path that stopped before playback in the Wine run. No game data used. Codex-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7329145725 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994#issuecomment-7329145725). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-01T23:16:39Z. --- The unmodified a_frame_is_recorded_and_replayed integration test at fccce4485 passed on native Windows. It recorded the synthetic scene (3 submissions, 4 lists, 18 resources, 6 pipelines), completed the added player.run with pace=f64::INFINITY, and reached the final replay assertions. The reported final picture hash matched the recording, 4aaec8b6026567d0. One test passed in 1.42 s. Command: cargo test --locked --profile diag --features diagnostics -p leonida-gpu --test replay -- --exact a_frame_is_recorded_and_replayed --nocapture This supplies a native result for the integration path that stopped before playback in the Wine run. No game data used. Codex-assisted.
MoonEyes commented 2026-12-02 12:34:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:34:32Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345544817 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994#issuecomment-7345544817). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:34:32Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
Kal0s-design commented 2026-12-02 14:43:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T14:43:05Z.


Ran natively on Windows 11, head fccce4485 merged into current main (2fc7383b9, clean merge). Below are handle counts for the Worker fix and timing for the pace change, each on main and on the PR.

Standard checks on the merge

Check Result
cargo test --locked -p leonida-gpu --lib --features diagnostics -- replay:: (WARP) 26 passed
cargo test --locked -p leonida-gpu --lib --features diagnostics (WARP) 778 passed, 0 failed, 59 ignored
--features diagnostics --test replay -- --exact a_frame_is_recorded_and_replayed 1 passed
cargo clippy -p leonida-gpu --all-targets --features diagnostics -- -D warnings no finding on a line this PR adds (the 10 findings are on existing lines)

Handle counts (GetProcessHandleCount, throwaway tests, not committed)

The Worker rows use the crate's host device. The Player rows run inside a_frame_is_recorded_and_replayed on the recorded synthetic capture, which always uses the default hardware adapter. Each loop ran after one warm-up.

Cycle Device main delta PR delta
Worker::new + drop, x1000 WARP +1000 0
Worker::new + drop, x1000 hardware +1000 0
new + run + idle + drop, x200 WARP / hardware +203 / +201 +3 / +1
new + send (no wait) + drop, x200 WARP / hardware +202 / +200 0 / 0
player.run(&plain), x20 hardware 0 0
Player::load + drop, x20 hardware +120 +40

The +1 to +3 left in the run/idle row appears on both sides, so it is noise.

By handle type, 30 Player::load + drop cycles on main left 120 Event, 30 Mutant and 30 Section handles. On the PR they left 30 Mutant and 30 Section. So each load leaked four events (four Workers per load for this capture), and the PR removes all four. The remaining +2 per load is not from Worker and I did not trace its source. Creating and releasing a DXGI factory, adapter and device in a loop adds 0, while creating and releasing a bare ID3D12CommandQueue adds +2 per cycle by count. So it may come from queue creation in Player::load, but I did not check the type of those handles.

Double close / use after close

Drop is the only CloseHandle site for Worker::event, Worker is not Clone, and Drop clears the field after closing it. Player::upload uses std::mem::replace to swap Workers. I reproduced that pattern 300 times: each pass created a temporary Worker, swapped it in, sent work on the original, swapped back, and dropped the temporary. It finished without error, and no delta went negative. wait registers SetEventOnCompletion and then blocks in WaitForSingleObject on the same thread. Because Worker is Send but not Sync, it cannot be dropped while another thread is waiting on it, and no fence registration is left pending at drop.

Pace

For finite positive values, pace_until gives exactly the same Instant as the old Instant::now() + Duration::from_secs_f64(pace / 1e3). I checked 90 values from 1e-9 to 8e9 ms. Timing of player.run on the synthetic capture, hardware adapter, median of 11 runs after one warm-up, both sides run back to back on an otherwise quiet machine:

pace (ms) main median (ms) PR median (ms)
0 33.0 27.9
1 45.1 41.2
5 97.8 89.7
20 291.0 271.0
NaN 46.5 28.6
inf panics (time.rs, from_secs_f64) 28.9
1e300 panics 28.0

Both sides add about 12.5 ms of run time per 1 ms of pace, so pacing of valid values is unchanged. The gaps between the two columns are run-to-run noise: an earlier pair of runs on a loaded machine had the PR slower at pace 20. The only behaviour change is that inf and overflowing values now run unpaced instead of panicking. NaN never panicked on main, because NaN > 0.0 is false, so the old code already skipped it. The PR description lists NaN among the panics it prevents. A large finite value is still accepted: pace_until(now, 1e15) returns a 1e12 s deadline, which spins in practice forever, as on main.

CI coverage

replay is compiled only with diagnostics. CI runs cargo test --workspace without that feature, and its only diagnostics step is --test replay. So worker_drop_closes_event_handle and pace_until_rejects_non_finite_and_overflowing_values do not run in CI, the same as the other replay:: unit tests. The pace: f64::INFINITY line added to the integration test does run in CI.

Not checked: an in-game run (the gate MoonEyes asked for), recording through Capture (the snap.rs Workers), and the debug layer.

GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7349019179 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994#issuecomment-7349019179). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T14:43:05Z. --- Ran natively on Windows 11, head `fccce4485` merged into current `main` (`2fc7383b9`, clean merge). Below are handle counts for the Worker fix and timing for the pace change, each on `main` and on the PR. **Standard checks on the merge** | Check | Result | |---|---| | `cargo test --locked -p leonida-gpu --lib --features diagnostics -- replay::` (WARP) | 26 passed | | `cargo test --locked -p leonida-gpu --lib --features diagnostics` (WARP) | 778 passed, 0 failed, 59 ignored | | `--features diagnostics --test replay -- --exact a_frame_is_recorded_and_replayed` | 1 passed | | `cargo clippy -p leonida-gpu --all-targets --features diagnostics -- -D warnings` | no finding on a line this PR adds (the 10 findings are on existing lines) | **Handle counts (`GetProcessHandleCount`, throwaway tests, not committed)** The Worker rows use the crate's host device. The `Player` rows run inside `a_frame_is_recorded_and_replayed` on the recorded synthetic capture, which always uses the default hardware adapter. Each loop ran after one warm-up. | Cycle | Device | `main` delta | PR delta | |---|---|---:|---:| | `Worker::new` + drop, x1000 | WARP | +1000 | 0 | | `Worker::new` + drop, x1000 | hardware | +1000 | 0 | | new + `run` + `idle` + drop, x200 | WARP / hardware | +203 / +201 | +3 / +1 | | new + `send` (no wait) + drop, x200 | WARP / hardware | +202 / +200 | 0 / 0 | | `player.run(&plain)`, x20 | hardware | 0 | 0 | | `Player::load` + drop, x20 | hardware | +120 | +40 | The +1 to +3 left in the run/idle row appears on both sides, so it is noise. By handle type, 30 `Player::load` + drop cycles on `main` left 120 Event, 30 Mutant and 30 Section handles. On the PR they left 30 Mutant and 30 Section. So each load leaked four events (four Workers per load for this capture), and the PR removes all four. The remaining +2 per load is not from Worker and I did not trace its source. Creating and releasing a DXGI factory, adapter and device in a loop adds 0, while creating and releasing a bare `ID3D12CommandQueue` adds +2 per cycle by count. So it may come from queue creation in `Player::load`, but I did not check the type of those handles. **Double close / use after close** `Drop` is the only `CloseHandle` site for `Worker::event`, `Worker` is not `Clone`, and `Drop` clears the field after closing it. `Player::upload` uses `std::mem::replace` to swap Workers. I reproduced that pattern 300 times: each pass created a temporary Worker, swapped it in, sent work on the original, swapped back, and dropped the temporary. It finished without error, and no delta went negative. `wait` registers `SetEventOnCompletion` and then blocks in `WaitForSingleObject` on the same thread. Because `Worker` is `Send` but not `Sync`, it cannot be dropped while another thread is waiting on it, and no fence registration is left pending at drop. **Pace** For finite positive values, `pace_until` gives exactly the same `Instant` as the old `Instant::now() + Duration::from_secs_f64(pace / 1e3)`. I checked 90 values from 1e-9 to 8e9 ms. Timing of `player.run` on the synthetic capture, hardware adapter, median of 11 runs after one warm-up, both sides run back to back on an otherwise quiet machine: | `pace` (ms) | `main` median (ms) | PR median (ms) | |---|---:|---:| | 0 | 33.0 | 27.9 | | 1 | 45.1 | 41.2 | | 5 | 97.8 | 89.7 | | 20 | 291.0 | 271.0 | | NaN | 46.5 | 28.6 | | inf | panics (`time.rs`, `from_secs_f64`) | 28.9 | | 1e300 | panics | 28.0 | Both sides add about 12.5 ms of run time per 1 ms of pace, so pacing of valid values is unchanged. The gaps between the two columns are run-to-run noise: an earlier pair of runs on a loaded machine had the PR slower at pace 20. The only behaviour change is that inf and overflowing values now run unpaced instead of panicking. NaN never panicked on `main`, because `NaN > 0.0` is false, so the old code already skipped it. The PR description lists NaN among the panics it prevents. A large finite value is still accepted: `pace_until(now, 1e15)` returns a 1e12 s deadline, which spins in practice forever, as on `main`. **CI coverage** `replay` is compiled only with `diagnostics`. CI runs `cargo test --workspace` without that feature, and its only diagnostics step is `--test replay`. So `worker_drop_closes_event_handle` and `pace_until_rejects_non_finite_and_overflowing_values` do not run in CI, the same as the other `replay::` unit tests. The `pace: f64::INFINITY` line added to the integration test does run in CI. Not checked: an in-game run (the gate MoonEyes asked for), recording through `Capture` (the `snap.rs` Workers), and the debug layer. GPUs tested: one NVIDIA desktop card + WARP. AI-assisted: yes (Claude Code).
MoonEyes commented 2026-12-02 16:10:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T16:10:24Z.


RUN (in game, batch of five render-path pull requests), each head merged with git merge --no-ff onto main 3c106eb2f, in one build: #2993 ddc10507d, #2889 bc390c26f, #2851 cf8f7be78, #2980 12c14a999, #2994 fccce4485. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 17.2, mean 17.3
Rendered fps, last 120 s median 17.3

For reference, the same machine and route rendered 13.3 to 16.7 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; free system memory median 2.5 GB; arrival in the world was driven by keys and not checked on pictures.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7351550405 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994#issuecomment-7351550405). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T16:10:24Z. --- RUN (in game, batch of five render-path pull requests), each head merged with `git merge --no-ff` onto main `3c106eb2f`, in one build: #2993 `ddc10507d`, #2889 `bc390c26f`, #2851 `cf8f7be78`, #2980 `12c14a999`, #2994 `fccce4485`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 17.2, mean 17.3 | | Rendered fps, last 120 s | median 17.3 | For reference, the same machine and route rendered 13.3 to 16.7 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; free system memory median 2.5 GB; arrival in the world was driven by keys and not checked on pictures. AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 18:18:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:18:51Z.


Verification of #2994 (third party, code review on Linux; not built: Windows-only leonida-gpu)

  • Head verified: fccce4485ef385508135837bd45a1127d17a2148 (3 files, +74/-4).
  • Merge base 66c79286f. git merge-tree --write-tree origin/main pr/2994 against main 45dc41f95 is clean.
    CI on the head: 6/6 success.
  • python -I scripts/check_no_game_data.py on the 3 files: exit 0.
  • The in-game gate is covered: MoonEyes's batch run on 3c106eb2f includes fccce4485 (PASS, no device loss).

Review

  • replay/gpu.rs:26-34 Drop for Worker closes the event made in Worker::new. Worker is neither Clone
    nor Copy, and event is only used in wait (gpu.rs:88-89), which waits INFINITE right after
    SetEventOnCompletion. No registration outlives a drop, so there is no double close and no late signal.
  • replay/play.rs:3504-3510 pace_until: on main, Duration::from_secs_f64(o.pace / 1e3) panics for NaN,
    infinity or overflow. The new function returns None for non-finite, zero, negative and overflowing values.
    This is the right guard. The unit test (play.rs:3558-3568) covers each case. The integration test runs
    player.run with pace: f64::INFINITY (tests/replay.rs:1810-1814), which panics on main's code, so that
    is a real red.
  • Test weakness: worker_drop_closes_event_handle (gpu.rs:480-513) returns without asserting when
    host() is None, in both parent and child, and prints nothing. On a machine with no device it passes
    silently. Print a skip line, as the crate's other device tests do.
  • Duplication nit: #3003 adds the same "close the event on drop" code for shown::saver. One OwnedEvent
    helper would serve both. Not blocking.

Process

  • The body says "AI-assisted" without naming the models or the reviewer agent (CONTRIBUTING.md).

Verdict: ready (not built here). There are two small nits (silent skip, duplication) and the model names
are missing from the body.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354350319 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994#issuecomment-7354350319). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:18:51Z. --- **Verification of #2994 (third party, code review on Linux; not built: Windows-only `leonida-gpu`)** - Head verified: `fccce4485ef385508135837bd45a1127d17a2148` (3 files, +74/-4). - Merge base `66c79286f`. `git merge-tree --write-tree origin/main pr/2994` against `main` `45dc41f95` is clean. CI on the head: 6/6 success. - `python -I scripts/check_no_game_data.py` on the 3 files: exit 0. - The in-game gate is covered: MoonEyes's batch run on `3c106eb2f` includes `fccce4485` (PASS, no device loss). **Review** - `replay/gpu.rs:26-34` `Drop for Worker` closes the event made in `Worker::new`. `Worker` is neither `Clone` nor `Copy`, and `event` is only used in `wait` (`gpu.rs:88-89`), which waits `INFINITE` right after `SetEventOnCompletion`. No registration outlives a drop, so there is no double close and no late signal. - `replay/play.rs:3504-3510` `pace_until`: on `main`, `Duration::from_secs_f64(o.pace / 1e3)` panics for NaN, infinity or overflow. The new function returns `None` for non-finite, zero, negative and overflowing values. This is the right guard. The unit test (`play.rs:3558-3568`) covers each case. The integration test runs `player.run` with `pace: f64::INFINITY` (`tests/replay.rs:1810-1814`), which panics on `main`'s code, so that is a real red. - Test weakness: `worker_drop_closes_event_handle` (`gpu.rs:480-513`) returns without asserting when `host()` is `None`, in both parent and child, and prints nothing. On a machine with no device it passes silently. Print a skip line, as the crate's other device tests do. - Duplication nit: #3003 adds the same "close the event on drop" code for `shown::saver`. One `OwnedEvent` helper would serve both. Not blocking. **Process** - The body says "AI-assisted" without naming the models or the reviewer agent (CONTRIBUTING.md). **Verdict: ready** (not built here). There are two small nits (silent skip, duplication) and the model names are missing from the body. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
bobcatchris commented 2026-12-02 21:02:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-02T21:02:31Z.


@MoonEyes Thank you for the review, and thank you @Kal0s-design, @andrew-ai, and @merzleckeier for the independent handle-count, native replay, and Wine verifications.

  • Updated the PR description's AI disclosure to name Gemini 4 Neon and the independent review pass.
  • Leaving exact head fccce4485 untouched so @MoonEyes's 16:10:24Z in-game batch PASS remains valid; the non-blocking nits (printing on child skip and deduplicating EventHandle with #2980/#3003) can be cleaned up in a follow-up once these land.

AI-assisted: Gemini 4 Neon

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358703364 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994#issuecomment-7358703364). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-02T21:02:31Z. --- @MoonEyes Thank you for the review, and thank you `@Kal0s-design`, `@andrew-ai`, and `@merzleckeier` for the independent handle-count, native replay, and Wine verifications. - Updated the PR description's AI disclosure to name `Gemini 4 Neon` and the independent review pass. - Leaving exact head `fccce4485` untouched so `@MoonEyes`'s `16:10:24Z` in-game batch PASS remains valid; the non-blocking nits (printing on child skip and deduplicating `EventHandle` with `#2980`/`#3003`) can be cleaned up in a follow-up once these land. AI-assisted: Gemini 4 Neon
fiestorra commented 2026-12-03 04:21:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T04:21:24Z.


VERIFY-2994 — cherry-pick limpio y 715/1: no añade ningún test numerado, y eso es lo que quiero señalar

git cherry-pick (sobre 516c9eaab)   3 files changed, 74 insertions(+), 4 deletions(-)
cargo test -p leonida-gpu --lib     715 passed; 1 failed; 59 ignored

715 es exactamente el número de main, y el 1 es la falla de la iGPU — o sea que el cambio no añade ningún test.

Y el título dice que cierra un Worker en su drop — la misma clase de arreglo que #3003 (el EventHandle), que revisé hace un rato. Dos PRs distintos, dos handles distintos, y en los dos el patrón es el mismo: un objeto que envuelve un HANDLE y no lo cierra. Si los dos entran, shown.rs y este tendrán el mismo Drop escrito dos veces — y la tercera vez será copiar y pegar otra vez. Un OwnedHandle compartido en el crate es lo que falta, y ninguno de los dos PRs lo propone porque cada autor estaba mirando su fichero.

Lo que verifiqué y lo que no: que aplica limpio y no rompe los 715, y que no trae test nuevo — la primera mitad es buena, la segunda es lo que le falta. La guarda de pp que menciona el título (guard p…) es justo lo que un test puede ejercitar sin el título, a diferencia del Drop de un handle, que necesita un proceso (como demostró #3003).

Así que le pediría lo mismo que a #3003: una prueba que corra en CI de lo que se pueda probar, y una línea diciendo qué no se puede.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7367548821 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994#issuecomment-7367548821). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T04:21:24Z. --- ## VERIFY-2994 — cherry-pick limpio y 715/1: **no añade ningún test numerado**, y eso es lo que quiero señalar ``` git cherry-pick (sobre 516c9eaab) 3 files changed, 74 insertions(+), 4 deletions(-) cargo test -p leonida-gpu --lib 715 passed; 1 failed; 59 ignored ``` **715 es exactamente el número de `main`**, **y el 1 es la falla de la iGPU** — **o sea que el cambio no añade ningún test.** **Y el título dice que cierra un `Worker` en su `drop`** — **la misma clase de arreglo que `#3003` (el `EventHandle`), que revisé hace un rato.** **Dos PRs distintos, dos handles distintos, y en los dos el patrón es el mismo: un objeto que envuelve un `HANDLE` y no lo cierra.** **Si los dos entran, `shown.rs` y este tendrán el mismo `Drop` escrito dos veces** — **y la tercera vez será copiar y pegar otra vez.** **Un `OwnedHandle` compartido en el crate es lo que falta**, **y ninguno de los dos PRs lo propone porque cada autor estaba mirando su fichero.** **Lo que verifiqué y lo que no**: **que aplica limpio y no rompe los 715**, **y que no trae test nuevo** — **la primera mitad es buena, la segunda es lo que le falta.** **La guarda de `pp` que menciona el título (`guard p…`) es justo lo que un test puede ejercitar sin el título**, **a diferencia del `Drop` de un handle, que necesita un proceso (como demostró `#3003`).** **Así que le pediría lo mismo que a `#3003`**: **una prueba que corra en CI de lo que se pueda probar, y una línea diciendo qué no se puede.**
merzleckeier commented 2026-12-03 04:24:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T04:24:24Z.


The unchanged fccce4485 adds two unit tests: worker_drop_closes_event_handle and pace_until_rejects_non_finite_and_overflowing_values. cargo test -p leonida-gpu --lib without diagnostics leaves the entire replay module out, which explains the unchanged count in the latest run.

I checked the hosted Windows job for this head. Its diagnostic step selected --test replay and reported a_frame_is_recorded_and_replayed as passed. That binary contains the new infinite-pace case. The step does not select either unit test, and the integration test can return early when there is no adapter. The logged ok alone does not establish that it reached the new case.

On Linux I compiled the exact pace_until function and unit test from the merged tree. The test passes, and it fails at the duration conversion with the old implementation. A CI follow-up can add cargo test -p leonida-gpu --features diagnostics --lib --locked -- replay:: alongside the existing integration step. This would select the pacing unit test even when the device-dependent tests skip. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7367606757 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2994#issuecomment-7367606757). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T04:24:24Z. --- The unchanged `fccce4485` **adds two unit tests**: `worker_drop_closes_event_handle` and `pace_until_rejects_non_finite_and_overflowing_values`. `cargo test -p leonida-gpu --lib` without `diagnostics` leaves the entire replay module out, which explains the unchanged count in the latest run. I checked the [hosted Windows job for this head](https://github.com/ProjectLeonida/mandy/actions/runs/46762924555/job/143055953074). Its diagnostic step selected `--test replay` and reported `a_frame_is_recorded_and_replayed` as passed. That binary contains the new infinite-pace case. The step does not select either unit test, and the integration test can return early when there is no adapter. The logged `ok` alone does not establish that it reached the new case. On Linux I compiled the exact `pace_until` function and unit test from the merged tree. The test passes, and it fails at the duration conversion with the old implementation. A CI follow-up can add `cargo test -p leonida-gpu --features diagnostics --lib --locked -- replay::` alongside the existing integration step. This would select the pacing unit test even when the device-dependent tests skip. AI-assisted with OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2994:upstream-pr/2994'
git switch 'upstream-pr/2994'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2994'
git switch 'upstream-pr/2994'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2994'
git switch 'upstream-pr/2994'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2994'
git switch 'main'
git merge --squash 'upstream-pr/2994'
git switch 'main'
git merge --ff-only 'upstream-pr/2994'
git switch 'main'
git merge 'upstream-pr/2994'
git push origin 'main'
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!2994
No description provided.