Skip to content

fix(videoout): cancel flips on a port the title closed instead of failing the driver - #1648

Merged
adriadam10 merged 6 commits into
boykopovar:mainfrom
Pedroj-64:fix/videoout-closed-port-flip-cancel
Oct 10, 2026
Merged

adriadam10 merged 6 commits into
boykopovar:mainfrom
Pedroj-64:fix/videoout-closed-port-flip-cancel

Conversation

@Pedroj-64

Copy link
Copy Markdown
Contributor

What

Follow-up to #1225 (split out because it widens that PR's scope). Part of #1040.

Closing a port while a flip is queued or being presented made checkConfig throw VideoOut: port is closed on the present thread, which terminated the process. That is the ps5-doom -timedemo exit reported on #1225 (I_Error → sceSystemServiceLoadExec("exit")).

A flip on a port the title closed is now cancelled: its pending counters and buffer reuse ticket are released and no failure is stored, so the driver and Shutdown stay clean. Real failures and process shutdown still propagate. RenderingWait no longer throws on a closed port for the same reason. Closed() and CheckAlive() split the old Check(), which is unchanged for title-facing calls.

testLifetime now expects cancellation (no failure, no pending flip, no stale counters on the reopened port, clean shutdown), and the reopen mode is registered in ctest.

Tested

Linux, SDL offscreen, lavapipe: video_out_flip_lifetime, _reopen, _decode, _controls pass. Without the src/include change lifetime fails and reopen aborts. tools/check_conventions.py --base upstream/main passes. Not tested on Windows or with ps5-doom itself.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: fix(videoout): report GPU driver shutdown failure from the present thread at Shutdown #1225 (its two commits appear here until it merges)
  • AI-assisted: no

@github-actions

github-actions Bot commented Oct 8, 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
#1655 core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp L215-225

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

I reviewed the full diff and built the exact PR head bed72585 locally in Release. The four registered Linux tests (video_out_flip_lifetime, reopen, decode, controls) pass 4/4; conventions pass as well. One required follow-up before merge: this head is 225 commits behind current main (merge base 4b005b22), and its declared prerequisite #1225 is still open. Please rebase the stack onto current main and rerun the exact-head checks, including Windows where these tests are registered. I will recheck the updated head then.

@MarcZX10

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

One additional Windows issue before the rebase: since #1367, SDL offscreen cannot create the Vulkan window used when these modes open a VideoOut port. The Windows report on #1225 tested a tree carrying this PR and saw lifetime, reopen, and controls fail at window creation (0/10); decode passed. Please adapt the Windows test registration/setup to skip cleanly when no Vulkan-capable window is available, while retaining the Linux offscreen coverage. The current all-platform SDL_VIDEODRIVER=offscreen entries will fail on the Windows CI runner.

Pedroj-64 and others added 4 commits October 9, 2026 06:53
…read at Shutdown

presentLoop called AgcDriverShutdown outside its try block, so a stored
worker failure rethrown there terminated the process. Store it in
flipQueue->failure so VideoOutDriver::Shutdown rethrows it after the join.

Register the lifetime, decode and controls modes of video_out_flip_tests
in ctest.
…Windows

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

The offscreen SDL driver cannot create a Vulkan window on Windows since
the VideoOut window uses SDL_WINDOW_VULKAN, so the tests that open a port
now exit 77 (skipped) like the other display tests, unless
ANYPS5_REQUIRE_DISPLAY is set. The tests also write app0/sce_sys/param.json,
which AppMetadata now requires.
@Pedroj-64
Pedroj-64 force-pushed the fix/videoout-closed-port-flip-cancel branch from bed7258 to c8a0622 Compare October 9, 2026 11:58
@Pedroj-64

Copy link
Copy Markdown
Contributor Author

Thanks @MarcZX100. The modes that open a port now exit 77 (skipped, SKIP_RETURN_CODE 77) when no Vulkan window can be created, the same way GuestVideoOutWqhdDetection does, so Linux keeps the offscreen coverage. Rebased onto the updated #1225 (c8a0622).

@rmz-24

rmz-24 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Windows results with a real Vulkan window, since under ctest the port-opening modes skip on Windows (SDL_VIDEODRIVER=offscreen): Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. c8a0622 cherry-picked onto current main d70b899 (applies cleanly), full build plus libs.

mode ctest (offscreen) run directly, real window real window, VideoOutDriver.* from main
lifetime skipped (77) passes VideoOut: port is closed
reopen skipped (77) passes VideoOut: port is closed
decode passes passes passes
controls skipped (77) passes passes

So on an actual Windows desktop the fix does what it says, and the two modes it targets fail without it. Without a desktop session, the skip on Windows means CI only covers decode there.

AI-assisted: yes

@MarcZX10

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

One contribution-rule issue remains in the test registration inherited from #1225: all four video_out_flip_* CTests use TIMEOUT 60, while current CONTRIBUTING.md requires each test to finish within 30 seconds and says to split or shrink slow tests rather than raise the timeout. The reported Linux passes do not include durations. Please set a 30-second limit if each mode stays within it, or split/shrink whichever mode does not; then include exact-head durations in the test report.

…ling the driver

A flip still queued or in presentation when the title closes its port is discarded, as on hardware, rather than stored as a driver failure. A closed port no longer terminates the presentation thread nor surfaces from Shutdown. The lifetime test now expects cancellation and the reopen mode is registered in ctest.
@Pedroj-64
Pedroj-64 force-pushed the fix/videoout-closed-port-flip-cancel branch from c8a0622 to a1efdab Compare October 9, 2026 14:42
@Pedroj-64

Copy link
Copy Markdown
Contributor Author

Thanks @MarcZX100. The four video_out_flip_* tests now use TIMEOUT 30 (59c98bd on #1225), and this PR is rebased onto it (a1efdab, no merge commit).

Durations on Linux with this head: decode 0.01 s; the three modes that open a port skip (exit 77) here because there is no Vulkan window, so I have no real-window durations. @rmz-24, if you can, could you add ctest -R video_out_flip --output-on-failure timings from your Windows desktop with the SDL default driver? I will shrink or split any mode that goes over 30 s.

@popcoder565

Copy link
Copy Markdown
Contributor

Real-window timings from a Windows desktop, since they were still pending. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. This PR's head a1efdab6 (which includes #1225's 59c98bde), merged onto main d70b899.

Each mode was run directly from the test's working directory with SDL's default video driver, 3 times:

mode result wall time
lifetime pass 3/3 0.75 to 0.87 s
reopen pass 3/3 0.67 to 0.72 s
decode pass 3/3 0.02 to 0.03 s
controls pass 3/3 0.67 to 0.69 s

All of them are far below the 30 s limit. Under ctest (SDL_VIDEODRIVER=offscreen), decode passes and the other three skip with 77, as described.

🤖 Addressed by Claude Code

@krishalivaibhav

Copy link
Copy Markdown
Contributor

Native Apple M2 validation confirms the shutdown behavior addressed by #1225 and the closed-port cancellation follow-up #1648.

Environment: Apple M2 / 16 GB, macOS 27.2 beta 3, Apple Clang 21 / SDK 27, bundled SDL compiled from source, MoltenVK 1.4.2. The local integration already included ARM64/macOS branch 11db79ae, placeholder-image #2015 (17713d1c), SPIR-V 1.3 #2191 (5463ea47), and visual-demo #2244 (1c71428f) on main d70b8998. These are combined-branch results, not either PR alone.

The existing video_out_flip_tests modes ran separately with 30-second timeouts, forced Apple M2 selection, required Vulkan/display initialization, and shader disk cache disabled. We used native Cocoa rather than SDL offscreen. The isolated working directory used the synthetic param.json structure from the existing WQHD fixture; an initial missing-metadata setup failure was corrected without changing production code.

An independent subagent reran pending-close, reopen, controls and presentation successfully, and reviewed error preservation and the macOS conflict resolution. No new production fix was authored. No games, full suite, or visible-output checks were performed; presentation results establish flip state and pacing, not pixel correctness. AI-assisted validation using Codex.

@Pedroj-64

Pedroj-64 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @popcoder565 for the real-window timings on Windows (all under 1 s, far from the 30 s limit), @rmz-24 for the results on a real desktop, and @krishalivaibhav for the Apple M2 validation, which confirms the clean flip cancellation on a closed port.

@MarcZX100 thanks for the review. The current head is a1efdab6, rebased onto #1225 (59c98bde) with no merge commit and with TIMEOUT 30. This PR still depends on #1225; if another rebase onto main is needed when it updates, I will do it.

@Pedroj-64

Pedroj-64 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Check: head a1efdab6 already includes the current main (0 commits behind), so the rebase @MarcZX100 asked for is done. The remaining prerequisite is that #1225 gets merged.

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked: build + scoped ctest on current main merged; video_out_flip_decode passes and the three port-opening modes skip under SDL offscreen (77) as designed. Run directly with a real window, lifetime, reopen, controls and decode pass; with src//include/ from main, lifetime fails and reopen aborts. Also confirmed on Windows (@rmz-24, @popcoder565) and Apple M2 (@krishalivaibhav). Merging.

Nit, not blocking: FlipRequest::Cancel() is declared and defined but unused; worth dropping in a follow-up. Note #1655 touches the same queue->changed lines, so whichever lands second needs a rebase.

@adriadam10
adriadam10 merged commit f399905 into boykopovar:main Oct 10, 2026
8 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…-port-flip-cancel

fix(videoout): cancel flips on a port the title closed instead of failing the driver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants