Skip to content

test(libScePad): wait for the read intervals the latch checks rely on - #12115

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
dantdmdarealguy:test/pad-latch-read-intervals
Nov 5, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
dantdmdarealguy:test/pad-latch-read-intervals

Conversation

@dantdmdarealguy

@dantdmdarealguy dantdmdarealguy commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What

guest_pad aborts now and then on Windows CI on main. It failed in 2 Windows jobs out of 1771 build.yml runs on main from 2026-10-26 00:00Z to 2026-10-27 20:30Z: 121861376042 (7e89ba1 + #10319) and 122201223723 (62b3ba2 + #11388). The test exits with 0xc0000409 and prints nothing, because Require calls std::abort(). Both stacks symbolize to CheckLatchedPressLifetime:

  • 62b3ba2: guest_pad_tests.exe+0x8f2e is the return from call abort in CheckLatchedPressLifetime(int).cold, and +0xa9e9 follows call CheckLatchedPressLifetime in main.
  • 7e89ba1 (rebuilt with the same compiler and flags): +0x86af and +0xaa08 map to the same two places.

Since #9919, the latch lasts one and a half times the interval between the previous two scePadReadState calls, kept between 100 ms and 500 ms. The latch checks assumed two things about scheduling:

  • Two consecutive reads land within microseconds of each other, so the latch is 100 ms and a tap 150 ms old has expired.
  • A read follows a tap within the latch.

A stall of about 100 ms between those reads breaks the first assumption. That happens on a CI runner running ctest --parallel 4, and it makes (data.buttons & cross) == 0 fail at GuestPad.cpp:283 or :293. A stall between a tap and its read breaks the second assumption (:294, :309, :329). Before #9919 the latch was a fixed 100 ms, and only :294 depended on timing.

The test now waits for the conditions it relies on:

  • ReadTwiceWithin repeats two scePadReadState calls until both finish within 50 ms. This makes the latch exactly 100 ms before the "expired" checks.
  • The "newer press drops an older latched press" check still releases the circle tap before reading it, so it shows that a released tap stays latched at the default 100 ms latch. Each attempt makes two reads within 50 ms, taps cross, waits 150 ms, taps circle and reads. It repeats until the read pair was close and the read finished within 50 ms of the circle press, at most 50 times, and aborts with released circle tap was not read within 50 ms of a close read pair in 50 attempts if no attempt did.
  • The slow-read and per-port cases repeat until the tap was read within 250 ms of the start of the second slow read. That is within the latch, which is at least 1.5 × 170 ms. It also keeps the following 400 ms check beyond the latch.

The library is unchanged.

Tested

Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release.

  • Without stalls, guest_pad passed 100/100 runs on its own (ctest -R "^guest_pad$" --repeat until-fail:100, 395.8 s, about 4.0 s per run, the same as main), and 100/100 with 8 instances running at a time.
  • I forced the stalls in copies of the test built outside the tree, with Require reporting its line, and ran 100 copies, 10 at a time. The main column is main's test against main's libScePad; line numbers are in main's GuestPad.cpp:
Stall injection main Change
One 120 ms sleep at the start of CheckLatchedPressLifetime (the CI window) 100/100 abort at :398 0/100
120 ms sleep with probability 1/6 before and after each publish and after each Require, inside the three latch checks 90/100 (:398 35, :408 9, :409 23, :424 11, :429 6, :444 6) 0/100
20 to 400 ms sleep with probability 1/4, same points 95/100 (:398 47, :408 11, :409 20, :424 8, :429 3, :444 6) 0/100
  • The checks catch the library bugs they were written for. I applied each mutation to PadState.cpp and ran builds where a failed Require prints its line and continues, so that every failing check shows:
Mutation of PadState.cpp main's test Previous revision (circle held) Change
A release drops the latched press at once newer-press check fails newer-press check passes newer-press check fails
A release drops the latched press when the latch is the default 100 ms newer-press check fails newer-press check passes newer-press check fails
Latch fixed at 100 ms (before #9919) slow-read and per-port checks fail same same
Without the expiry reset on a newer press (#7059 follow-up) newer-press check fails same same

Without a mutation all three pass 5/5. The first two mutations also make the earlier CheckTapBetweenReads fail, so the unmodified test binary aborts there first. The rows show the newer-press check on its own.

  • ctest -R "^guest_pad|patched_libraries" passes 3/3. The full build and the libs target both succeed with no warnings in GuestPad.cpp. check_test_registration.py and check_conventions.py --base origin/main pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none (Windows CI flake in guest_pad)
  • GPUs tested: n/a
  • AI-assisted: yes, some AI assistance was used

The latch lasts one and a half times the interval between the previous
two scePadReadState calls, kept between 100 ms and 500 ms. The latch
checks assumed two consecutive reads land within a few microseconds and
that a read follows a tap within the latch, so a stall of about 100 ms
on a loaded runner made them fail: guest_pad aborted in
CheckLatchedPressLifetime in two Windows CI runs on main.

Repeat the two short reads until both finished within 50 ms, hold the
newer press while it is read, and repeat the slow-read and per-port
cases until the tap was read within 250 ms of the second slow read.
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 8260 core/libs/tests/GuestPad.cpp
PR 13486 core/libs/tests/GuestPad.cpp
PR 14124 core/libs/tests/GuestPad.cpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head 94df21e84d94f8d847d74107d27a731d1ca6f356. The change keeps the library untouched and makes each timing assumption explicit in the test: it establishes a short read interval before expiry checks and retries the slow-read cases until the post-tap read is within the computed latch window. The newer-press case reads while the newer button is still down. The reported stall-injection and mutation runs give useful evidence that it avoids the CI scheduling flake without masking the existing latch regressions.

Independent checks: GuestPad.cpp syntax-only compilation passed with the project GCC 12/C++20 flags, git diff --check passed, and merge preview against current main is clean. Hosted Windows CI passed. I did not independently run the Windows stress tests on this Linux host.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@dantdmdarealguy thanks, the interval analysis matches PadState.cpp (the latch uses the previous two reads' interval, and the retry bounds in the slow-read and per-port cases hold). One check got weaker: in CheckLatchedPressLifetime the circle tap is now held while it is read, so circle != 0 is true for any held button and no longer shows that a released tap is still latched at the default 100 ms latch (the old version released it before the read). Please keep the tap-and-release form there and make it deterministic the same way as the other cases: retry the block until the read follows the tap within 50 ms, with the read pair before it close together so the latch is 100 ms.

@oneandonlydean oneandonlydean self-assigned this Oct 28, 2026

@THEMANnt THEMANnt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 94df21e84d94f8d847d74107d27a731d1ca6f356 against f5fefb982c53672bda23767304f97aac2eec5207. The Pad latch checks establish the intended fast/slow read intervals before asserting latch behavior, and keep a currently held replacement button down until its state is read. The retry windows are timing preconditions; the focused CTest has an external timeout. A successful local run is not proof of scheduler behavior under every load. No actionable finding in this scoped test review.

Windows/GCC 15.3 Release: configured and built the registered target from pinned sources; focused CTest: 1 passed, 0 skipped. Checked that the fixture assertions remain active in Release. Production source is unchanged from the author base; baseline was source-compared, not rebuilt/rerun here. Matching cached dependency source pins and the existing matching FFmpeg package are used. No game, physical-console or GPU validation is claimed.

The newer-press case in CheckLatchedPressLifetime held the circle press
while it was read, so the check passed for any held button and no longer
showed that a released tap stays latched at the default 100 ms latch.

Release the circle tap before the read again. Each attempt makes two
reads within 50 ms, so the latch is 100 ms, taps cross, waits 150 ms,
taps circle and reads it. Repeat up to 50 times until the reads were
close and the read finished within 50 ms of the circle press, and abort
with a message if no attempt did.
@dantdmdarealguy

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Thanks, fixed in 90e7ebe: the circle tap is released before the read again. Each attempt makes a read pair within 50 ms (so the latch is 100 ms), taps cross, waits 150 ms, taps circle and reads it. The block repeats until the pair was close and the read came within 50 ms of the press, at most 50 times, and aborts with a message otherwise. With a PadState.cpp mutation that drops a latched press on release, the changed check fails 5/5 like the original did, while the held-button version passed it. Without stalls guest_pad passed 100/100 serially and 100/100 with 8 at a time. With 20 to 400 ms stalls injected at a quarter of the publish/read points it passed 100/100, where main's test fails 95/100.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head 90e7ebe merged onto main 7feb37e · tested 2026-11-03 06:11 UTC · 15 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 1,058 passed · 4 failed (0 new, 3 also fail on main, 1 unstable on main) · 7 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 1,069 of 3,743 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (517 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.3 s, ⚠️ public_headers 55.4 s, ⚠️ agc_driver_image_sample_unnormalized 44.7 s, ⚠️ agc_driver_lazy_resolved_abi 37.9 s, ⚠️ agc_driver_sample_multisample_target 31.3 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 5 of the last 7 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
Validation IDs already present on main (4 IDs in 441 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (441 tests): agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, agc_driver_bindless_images, and 433 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
Skipped (7)
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
Reproduce
git fetch origin 90e7ebec1fb20765ffca5e7df0e022439a621b53 7feb37ee3e30e10139b483fb4df689d5b5b69ab8
git checkout 7feb37ee3e30e10139b483fb4df689d5b5b69ab8 && git merge --no-ff 90e7ebec1fb20765ffca5e7df0e022439a621b53
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@B-Howell

B-Howell commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Tested 90e7ebec1f merged onto main 1c8c0efc8c on Windows 11, Ryzen 7 7800X3D, WinLibs GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON.

This flake also breaks other PRs' CI. The same guest_pad abort (0xc0000409 at about 1 s, no output) shows up in several hosted windows runs since 2026-10-28. These include main workflow_dispatch runs 41260412986 and 40735895035, #9742's 41656851495 and #15653's 41743988397. In three of those four logs guest_pad is the only failing test. 41260412986 also has three check_compile_modes_test_* timeouts.

Without stalls: ctest -R "^guest_pad$" --repeat until-fail:20 gives 20/20 (5.2-5.5 s). Running it CI's way, --parallel 4 --timeout 120 --repeat until-fail:10 alongside its 31 neighbours (guest_pad*, guest_savedata*, guest_screenshot*, guest_share*, guest_social_screen*, guest_sp_syscall_wrapper, guest_ssl*), all 32 tests pass 10/10.

One 110 ms sleep at each read gap that a latch check depends on, on both sides, run 3 times each. Require was changed to print its line (with #line keeping the numbering). Line numbers in the table are main's GuestPad.cpp.

Stall main #12115
Before the read at :391 (the pair the first "expired" check uses). On #12115, inside the ReadTwiceWithin loop before it 3/3 abort :398 3/3 pass; the stalled pair is retried once
Between the reads at :397 and :399 (the CI failure). On #12115, inside the ReadTwiceWithin in the circle loop 3/3 abort :408 3/3 pass; one retry
Between the tap and the read in CheckLatchedPressAtSlowReads (:421/:423) 3/3 abort :424 3/3 pass; one retry
Between the tap and the read in CheckLatchedPressPerPort (:442/:444) 3/3 abort :444 3/3 pass; one retry

Every attempt stalled (the retry bound is never met):

  • Circle loop: after 50 attempts it aborts in 16.8 s with released circle tap was not read within 50 ms of a close read pair in 50 attempts.
  • The other three loops have no bound: while (!ReadTwiceWithin(...)) {} at :286 of the PR head, and the two do ... while (... > 250ms) loops at :330 and :356. Each one spun until ctest's 120 s timeout, after 956, 265 and 263 attempts, with no message. A runner that stays loaded would turn this flake into a silent ***Timeout. It would also hold one --parallel 4 slot for 120 s. A cap and a message like the circle loop's would make that failure readable.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit 6fe3595 into boykopovar:main Nov 5, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants