Skip to content

fix(agc): do not abort on a screenshot trigger that another process holds open - #20344

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
xXPBSXx:fix/agc-screenshot-trigger-held-open
Nov 26, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
xXPBSXx:fix/agc-screenshot-trigger-held-open

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

What

With APS5_SCREENSHOT_TRIGGER set, AgcDriver::Screenshot::Take() deletes the trigger file to request a PNG of the next presented frame. If the deletion failed, it threw, and the uncaught exception ended the emulator. That happened in a run of PPSA15065 on 2026-11-14: Windows refused the deletion because the file was in use by another process, and the run ended with driver failure, presentation failed and abort() (SIGABRT) (the first comment has those lines). Which process held the file is not shown by the log.

Now a failed deletion is reported once on stderr ([gpu] screenshot trigger cannot be consumed yet, trying again at the next frame: <system message>) and Take() returns false for that frame. The file stays, the next frame tries again, and the screenshot is taken at the first frame after the other process lets go. The message is printed once until a deletion succeeds (a static flag, cleared after a success), not once per frame. A trigger that cannot be inspected or is not a regular file still throws as before. One clause in the APS5_SCREENSHOT_TRIGGER row of docs/dev/ENVIRONMENT.md says that a trigger another process holds open is retried at the next frame.

A trigger that can never be deleted (for example in a directory without write access) is no longer fatal either: it is tried again at every frame, the message is printed once, and no screenshot is taken. This is deliberate, because the trigger is a development aid and a run should not end because of it; it follows from the code, and no such case was run.

The test commit holds the trigger file open without sharing (CreateFileW, share mode 0) and checks that Take() does not throw, returns false, and leaves the file; after the handle is closed, the next Take() returns true and the file is gone. The test is compiled on Windows only: deleting an open file succeeds on POSIX systems, so the case is not reproduced there, and the changed path was not run on Linux or macOS. No title run with this change was made, so the PPSA15065 run is the reason for the change, not a measured improvement.

Tested

Windows 10 Pro 10.0.19045, on 2026-11-14 (21:16 UTC and 21:19 UTC). Both runs are on base upstream/main 5cc140af097, which is an ancestor of current main (a merge of this branch into main fca835affc3 is clean). ninja returned 0 for each head before its tests ran. The agc_screenshot and agc_screenshot_trigger tests, the second with the argument trigger, are the only ones run; they are in the first comment.

State agc_screenshot agc_screenshot_trigger
test commit only (the state before the fix) passes fails (1 of 2 tests failed)
with the fix and the documentation passes passes; the message above appears once in its output

There is no console measurement: the trigger is an emulator development aid with no console counterpart. tools/check_conventions.py --base 5cc140af097 passes. The change is 3 files, +28/-2. GPUs: the two tests only call AgcDriver::Screenshot and the PNG encoder; their source names no Vulkan symbol and the logs contain no Selected GPU line, so no GPU was involved. Not tested: Linux, macOS, the CI runner, a title run with this change, a trigger that stays undeletable, and holding the trigger open by a process other than the test itself.

Overlap: the 114 other open pull requests that change one of the three files of this branch (almost all of them through docs/dev/ENVIRONMENT.md; found by reading the changed files of all 1517 open pull requests at about 00:35 UTC) were test-merged on 2026-11-15 at about 00:38 UTC against main ef3fafb2269 (the branch is based on 5cc140af097, which is an ancestor of it); the branch merges into it without a conflict. 61 of them already conflict with main without this change and still conflict with it, 53 merge cleanly with and without it; none conflicts only with this change, so the changed row of APS5_SCREENSHOT_TRIGGER in docs/dev/ENVIRONMENT.md collides with none. No open pull request changes AgcDriver::Screenshot (Screenshot.cpp, triggered(), Take()) or its test, and none has the screenshot trigger in its title.

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
  • GPUs tested: n/a (the tests open no Vulkan device)
  • AI-assisted: yes

xXPBSXx and others added 2 commits November 14, 2026 22:10
When another process holds the APS5_SCREENSHOT_TRIGGER file open on
Windows, removing it fails and Screenshot::Take throws, which aborts the
title (a bot run ended that way after a screenshot request). The test
holds the trigger open, expects Take to return without a request and
without throwing, and expects the released trigger to be consumed at the
next call.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…xt frame

Screenshot::Take threw when removing the APS5_SCREENSHOT_TRIGGER file
failed, for example while another process still had it open on Windows,
and the throw aborted the title. A removal that fails is now reported once
and the trigger is tried again at the next frame; the screenshot is taken
once the file can be removed. A trigger that is not a regular file or
cannot be inspected still throws.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Evidence for this pull request: the failure from the PPSA15065 run of 2026-11-14 that prompted it, and the output of the two test runs. The first block is the stderr of that run from the line driver failure on (the screenshot saved lines before it are omitted; the OS message is German and says that the process cannot access the file because it is being used by another process; the thread number is replaced by N). The second block is the test output of the red run (test commit only) and the green run (with the fix) on the same base; the lines naming the local test executables are removed, the rest is as written by ctest.

run log, failure
[gpu] driver failure: Screenshot: cannot consume trigger file: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird
[videoout] presentation failed: Screenshot: cannot consume trigger file: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird
terminate called after throwing an instance of 'std::runtime_error'
  what():  Screenshot: cannot consume trigger file: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird
FATAL: abort() (SIGABRT) on thread N
test output, red and green
=== ROT 2026-11-14 21:16 UTC HEAD 60bff57e4cee (Test-Commit) Basis upstream/main 5cc140af097, ninja rc=0
    Start 2982: agc_screenshot
2982: agc screenshot tests passed
1/2 Test #2982: agc_screenshot ...................   Passed    5.55 sec
    Start 2983: agc_screenshot_trigger
2/2 Test #2983: agc_screenshot_trigger ...........***Failed    5.34 sec
The following tests passed:
	agc_screenshot
50% tests passed, 1 tests failed out of 2
	2983 - agc_screenshot_trigger (Failed)

=== GRUEN 2026-11-14 21:19 UTC HEAD f824cbbbcac1 (Test+Fix+Doku) Basis upstream/main 5cc140af097, ninja rc=0 (ninja=0)
2982: agc screenshot tests passed
1/2 Test #2982: agc_screenshot ...................   Passed    5.09 sec
2983: [gpu] screenshot trigger cannot be consumed yet, trying again at the next frame: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird
2983: agc screenshot tests passed
2/2 Test #2983: agc_screenshot_trigger ...........   Passed    4.96 sec
The following tests passed:
100% tests passed, 0 tests failed out of 2

AI-assisted (Claude Code).

@github-actions github-actions Bot added docs agc libSceAgc* labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 26913 docs/dev/ENVIRONMENT.md L213-214

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 1896 docs/dev/ENVIRONMENT.md
PR 4472 docs/dev/ENVIRONMENT.md
PR 6186 docs/dev/ENVIRONMENT.md
PR 6924 docs/dev/ENVIRONMENT.md
PR 7275 docs/dev/ENVIRONMENT.md
PR 7642 docs/dev/ENVIRONMENT.md
PR 7643 docs/dev/ENVIRONMENT.md
PR 9289 docs/dev/ENVIRONMENT.md
PR 9345 docs/dev/ENVIRONMENT.md
PR 9356 docs/dev/ENVIRONMENT.md
PR 9387 docs/dev/ENVIRONMENT.md
PR 9508 docs/dev/ENVIRONMENT.md
PR 9712 docs/dev/ENVIRONMENT.md
PR 9852 docs/dev/ENVIRONMENT.md
PR 10193 docs/dev/ENVIRONMENT.md
PR 10442 docs/dev/ENVIRONMENT.md
PR 11435 docs/dev/ENVIRONMENT.md
PR 11436 docs/dev/ENVIRONMENT.md
PR 12324 docs/dev/ENVIRONMENT.md
PR 12746 docs/dev/ENVIRONMENT.md
PR 12849 docs/dev/ENVIRONMENT.md
PR 13809 docs/dev/ENVIRONMENT.md
PR 13863 docs/dev/ENVIRONMENT.md
PR 13920 docs/dev/ENVIRONMENT.md
PR 13928 docs/dev/ENVIRONMENT.md
PR 13929 docs/dev/ENVIRONMENT.md
PR 14262 docs/dev/ENVIRONMENT.md
PR 15456 docs/dev/ENVIRONMENT.md
PR 15548 docs/dev/ENVIRONMENT.md
PR 15570 docs/dev/ENVIRONMENT.md
PR 16217 docs/dev/ENVIRONMENT.md
PR 16793 docs/dev/ENVIRONMENT.md
PR 16831 docs/dev/ENVIRONMENT.md
PR 17557 docs/dev/ENVIRONMENT.md
PR 17719 docs/dev/ENVIRONMENT.md
PR 17729 docs/dev/ENVIRONMENT.md
PR 18082 docs/dev/ENVIRONMENT.md
PR 18173 docs/dev/ENVIRONMENT.md
PR 18226 docs/dev/ENVIRONMENT.md
PR 20172 docs/dev/ENVIRONMENT.md
PR 20248 docs/dev/ENVIRONMENT.md
PR 20315 docs/dev/ENVIRONMENT.md
PR 20519 docs/dev/ENVIRONMENT.md
PR 21211 docs/dev/ENVIRONMENT.md
PR 21225 docs/dev/ENVIRONMENT.md
PR 21238 docs/dev/ENVIRONMENT.md
PR 22071 docs/dev/ENVIRONMENT.md
PR 22190 docs/dev/ENVIRONMENT.md
PR 22424 docs/dev/ENVIRONMENT.md
PR 22434 docs/dev/ENVIRONMENT.md
PR 22647 docs/dev/ENVIRONMENT.md
PR 23975 docs/dev/ENVIRONMENT.md
PR 24661 docs/dev/ENVIRONMENT.md
PR 26165 docs/dev/ENVIRONMENT.md
PR 26365 docs/dev/ENVIRONMENT.md
PR 26613 docs/dev/ENVIRONMENT.md
PR 27133 docs/dev/ENVIRONMENT.md

@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 — no blocking findings

The changed code handles a trigger removal error by deferring the trigger request and retrying on a later frame; I did not run the reported Windows tests, so the review does not establish that they pass.

What I ran

Inspected head f824cbbbcac1c249917d6817b05d743f5e1f60e8 using the prepared review bundle and pinned repository reader. No test or build command was run.

Results

Check Result Note
Changed code review passed All three changed files read
Tests and build not run Windows results are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

The reported Windows 10 test runs, Linux and macOS behavior, CI, and a title run were not independently verified. The files read were core/libs/prx/libSceAgcDriver/Execution/src/Screenshot.cpp, core/libs/prx/libSceAgcDriver/tests/Screenshot.cpp, and docs/dev/ENVIRONMENT.md; all three files listed in the manifest as reviewed were read. No changed files were excluded.

To get this to a good state

Nothing is required.

@rafaconvaitis

Copy link
Copy Markdown
Contributor

A second occurrence in the wild, this time with a likely holder, and a Windows run of this head.

Occurrence. main 928e3dd808, Windows 11 25H2 (build 26200), NVIDIA GeForce RTX 3050 6 GB (driver 610.88), ps5-signal-companion (PPSA69426 v00.006.000) with APS5_SCREENSHOT_TRIGGER set. A script made the request 30 s into the run by creating the trigger with a plain open, write and close. The title looked at the file between the create and the close:

[gpu] driver failure: Screenshot: cannot consume trigger file: <the Windows message for ERROR_SHARING_VIOLATION, file in use by another process>
[videoout] presentation failed: Screenshot: cannot consume trigger file: <same message>
terminate called after throwing an instance of 'std::runtime_error'

and the process ended with exit code 0xc0000409.

  • The only process known to touch the file was the script that was creating it; a virus scan of the new file cannot be ruled out. So the documented way of making a request, creating a regular file, is enough to hit this, without a third tool.
  • The window is narrow: the same script had made 16 requests in runs of other titles earlier that day without a collision.
  • Until this is merged, creating the trigger under another name and renaming it into place avoids the open handle on the watched path.

This head on Windows. Head f824cbbbca merged alone onto main 046d99ed28 (git merge --no-ff, clean merge), WinLibs GCC 15.2.0 r7 UCRT, Release, ctest -R '^agc_screenshot' -V -j 1, 3 runs per cell, with each GPU of the machine selected through ANYPS5_GPU (AMD Radeon 760M, AMD Software 26.11.2; NVIDIA GeForce RTX 3050, 610.88):

test main this PR
agc_screenshot passes 3/3 with either GPU passes 3/3 with either GPU
agc_screenshot_trigger passes 3/3 with either GPU passes 3/3 with either GPU

AI-assisted: yes (runs scripted with an AI assistant, on the hardware above).

@xXPBSXx

xXPBSXx commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the second occurrence and for running this head on Windows.

The holder. The first report could not say which process held the trigger file. Yours points at the script that creates it: between its create and its close, the file is open without sharing for deletion, and the watched path is looked at in that window. That fits what this change handles: Take() no longer throws when the deletion fails, it reports the failure once on stderr and tries again at the next frame, so a request made with a plain open, write and close is taken at the first frame after the close. It also means no third tool is needed to reach the failure.

The table. Both columns pass 3/3 on both GPUs. The held-open case is a new case in this pull request's test commit, so the main column runs the test file without it; I read that column as "no failure without the new case", not as a red run of the fix. The red run of the new case on main is in the first comment of this pull request (the second block, test commit only).

What is not shown. Your title run (PPSA69426) was on main 928e3dd808; this head was run through ctest only, so the title with the script has not been run with the fix. The rename workaround you describe avoids the open handle on the watched path and needs no change here. I did not change the documentation row for it in this pull request.

AI-assisted (Claude Code).

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head f824cbbbca, applied with git apply on main fd4aeed483 together with the other 25 PRs of one batch (#24107, #24132, #24238, #15143, #22088, #22685, #23739, #24032, #16054, #20001, #24170, #24396, #16856, #17298, #20497, #23347, #24426, #24554, #24598, #21376, #21556, #22047, #22082, #14124, #18476). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
guest_screenshot, guest_screenshot_checks, guest_screenshot_large_overlay (3 tests, matched by name to the test file this PR changes) all pass outside the iGPU subset

Whole batch: the full ctest -j 12 (6524 tests) on the RTX 3080 has 8 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. Traced to other PRs of the batch, each by reverting it and testing again: #21556 (guest_json_allocator), #16856 (guest_kernel_sys_module_internal), #15143 (guest_math_exact); none is in this PR's area. Failing tests I could not trace to a single PR (reverting the likely candidates did not clear them): public_headers. The 2127 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants