Skip to content

fix(videoout): keep the last display mode while the host reports no display - #25943

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
mrfelek:fix/videoout-keep-mode-without-display
Nov 24, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
mrfelek:fix/videoout-keep-mode-without-display

Conversation

@mrfelek

@mrfelek mrfelek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

What

The presenter calls VideoOutDriver::updateDisplayRefreshRate() on every pass of its event loop. When SDL finds no display for the window, which happens while a monitor sleeps or drops its DisplayPort or HDMI link, SDL_GetWindowDisplayIndex fails, the function throws, and the presentation thread turns the exception into std::terminate:

[videoout] presentation failed: SDL_GetWindowDisplayIndex failed: Couldn't find any displays
terminate called after throwing an instance of 'std::runtime_error'

A title that has been running for an hour stops this way when the monitor goes into power saving, for example during play with a controller only, since controller input does not keep the desktop's display awake.

The change: updateDisplayRefreshRate() keeps the last measured refresh rate and resolution when the display index or the display mode cannot be read, and the title keeps running; the next successful read updates them again. When no mode was ever measured, it still stops with the same message, so a title started while the display sleeps behaves as docs/dev/GAME_TESTING.md describes. The decision is a small function, KeepHostDisplayMode() in HostDisplayMode.hpp, so it can be tested without a display.

Tested

Linux 7.3, RTX 3080 Ti, NVIDIA 615.71.09, Release.

  • The branch is that change rebased onto main 1ec0df1aee; the 16 commits in between do not touch libSceVideoOut.
  • New test video_out_host_display_mode: no display before any mode stops with the lookup failure; the first measured mode is taken; with no display afterwards the known mode is kept; a new measurement replaces it.
  • Focused tests: ^video_out_ with ANYPS5_VIDEO_OUT_TEST_DRIVER=x11, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V, on this change on main 7dad980505 and on that main: 46 of 46 and 45 of 45 pass, the loader inserted the layer 33 times in each log and never reported it missing, and neither log has a VUID- line.
  • PPSA21564: before, a session stopped with the message above after about an hour of play, when the display went to sleep. With the change, the title kept running through display power-off tests (kscreen-doctor --dpms off for 30 s and for 3 min, and the monitor's power button). In those tests the X server kept listing both outputs, so SDL never reported zero displays: the no-display path itself is covered by the new test, not by these runs.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: NVIDIA RTX 3080 Ti, driver 615.71.09, Linux 7.3
  • AI-assisted: yes

@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 — looks good

The display mode fallback retains the last successfully measured values after SDL lookup failures, and the focused tests reported by the author cover the policy; I did not run checks in this review.

What I ran

Reviewed head 7859c5d74b1279894f35a79e41aeb6448117aaee using the prepared diff and pinned repository reader. No commands or tests were run.

Results

Check Result Note
Diff and changed code review passed All five changed files read
Tests in this review not run Author reports focused tests passed

Findings

Blocking

None.

Non-blocking

None.

Not verified

Builds and tests were not run. Runtime behavior on physical consoles and host display configurations beyond the author-reported Linux setup were not verified. No files were excluded from the prepared manifest; all five files marked for review were read.

To get this to a good state

Nothing is required.

@HPHM277

HPHM277 commented Nov 23, 2026

Copy link
Copy Markdown

Tested the patch from 7859c5d74b against main at 441fa65119 on Windows 11 build 26100, RTX 4060 Laptop GPU (NVIDIA 617.42), WinLibs GCC 15.2.0, Release.

The focused CTests video_out_output_mode_policy and video_out_flip_resolution passed on both builds. The PR’s new video_out_host_display_mode also passed, giving 2/2 on the baseline and 3/3 with the patch. The flip test selected the RTX 4060 Laptop GPU and loaded VK_LAYER_KHRONOS_validation on each build, with the shader cache disabled and no VUID- messages in either log.

I also compiled each revision’s updateDisplayRefreshRate() method into a small harness with simulated SDL display lookups. After an initial 1080p/60 Hz sample, I separately made the display-index lookup and the current-mode lookup fail. The baseline threw on both failures. With the patch, both calls returned and retained 1080p/60 Hz. A subsequent successful sample updated the stored mode to 1440p/120 Hz. Starting with no prior sample still raised the lookup error on both revisions.

The disconnect and reconnect were simulated; the physical monitor remained connected. AI-assisted local verification (Codex).

@Helldiverr

Copy link
Copy Markdown
Contributor

Run on Windows with an AMD GPU and the validation layer: the change looks correct. This is not a GPU result. The change is host-side SDL display handling, and the GPU is incidental to it:

  • New test is host-only. video_out_host_display_mode creates no Vulkan device and makes no SDL calls.
  • Flip tests. The four video_out_flip_* tests do create a device on the R9700 and present to a real SDL window. They exercise the new updateDisplayRefreshRate() only on its success path, unless the lookup failure is injected as described below.

On head 7859c5d74b all 6 focused tests pass 3/3, with no VUID-. With a display loss injected into the real presenter, main reproduces the reported std::terminate in all four flip tests, and the head keeps presenting.

What this run adds. Two reviews already exist:

  • HPHM277: RTX 4060 Laptop on Windows. Ran video_out_output_mode_policy, video_out_flip_resolution and the new test. Also compiled each revision's updateDisplayRefreshRate() into a separate harness with simulated SDL lookups.
  • MarcZX10: approved without running tests.

The author ran Linux on an RTX 3080 Ti with DPMS tests. There, X kept both outputs listed, so the no-display path itself was never reached.

Mine adds the following:

  • First AMD and RDNA4 run.
  • The no-display path in the real driver. I injected the failure into the production VideoOutDriver inside the real presenter thread, not in a separate harness. This runs with the SDL Windows video driver, a Vulkan swapchain on the R9700 and the validation layer. The method is a local, uncommitted change, now reverted (see No-display injection).

Code.

  • Change. updateDisplayRefreshRate() now routes both SDL failures through KeepHostDisplayMode(). That function returns the new measurement, or else the last known mode, or else throws the original message. The decision is unit-tested.
  • Threading. Both call sites, the start of presentLoop and the event pump, run inside OnMainThread, so the new non-atomic std::optional<HostDisplayMode> knownDisplayMode is only touched from one thread. The published values stay in the existing atomics.
  • Rules. There are no code comments, no made-up success and nothing title-specific; it applies to any host display loss. No debt fragment is needed. tools/check_conventions.py --base upstream/main passes on the merge.

No-display injection (local, reverted). I replaced the SDL_GetWindowDisplayIndex call so that, with PROBE_NO_DISPLAY set, every call after the first sets SDL_SetError("Couldn't find any displays") and returns -1. Each failing call prints a probe: line. I applied the same patch to main and to the merged head; both patches are saved next to the logs. I then ran the four flip tests with the variable set:

  • main c475bd9c77. All four flip tests (resolution, present, pacing, fps_limit) exit with 0xc0000409. Each logs [videoout] presentation failed: SDL_GetWindowDisplayIndex failed: Couldn't find any displays and then terminate called after throwing an instance of 'std::runtime_error'. That is the trace in the description.
  • Head. All four pass. Every lookup after the first failed, and the presenter kept the 60 Hz it had measured: for example still presenting at call 7, refresh 60 in fps_limit. The runs are short, so each test made only 2 to 7 lookups: 2 in resolution, 5 in present and pacing, and 7 in fps_limit. No presentation failed line appears.
  • Head, failing from the first lookup. I also made every lookup fail, including the first. video_out_flip_present then fails at start-up with SDL_GetWindowDisplayIndex failed: Couldn't find any displays, before any Vulkan instance is created. That is the behaviour the description keeps for a title started while the display sleeps.

This simulates the loss only at the SDL lookup. The monitor stayed connected, and I did not test a real DisplayPort or HDMI drop.

Negative control. video_out_host_display_mode cannot be built on main, because KeepHostDisplayMode does not exist there, so main ran the other 5 tests. The injection above is the functional negative control.

GPU. Head 7859c5d74b, merged cleanly onto main c475bd9c77:

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R "^(video_out_host_display_mode|video_out_output_mode_policy|video_out_flip_resolution|video_out_flip_present|video_out_flip_pacing|video_out_flip_fps_limit)$" -V
run host_display_mode output_mode_policy flip_resolution flip_present flip_pacing flip_fps_limit
main not built Passed 0.04 s Passed 1.76 s Passed 0.75 s Passed 1.32 s Passed 0.78 s
head 1 Passed 0.03 s Passed 0.04 s Passed 0.70 s Passed 0.69 s Passed 1.31 s Passed 0.79 s
head 2 Passed 0.03 s Passed 0.03 s Passed 0.61 s Passed 0.62 s Passed 1.30 s Passed 0.79 s
head 3 Passed 0.03 s Passed 0.03 s Passed 0.55 s Passed 0.63 s Passed 1.31 s Passed 0.76 s

The four flip tests each selected AMD Radeon AI PRO R9700 and presented through SDL_VIDEODRIVER=windows. host_display_mode and output_mode_policy log no loader lines and create no device.

Validation.

  • Focused-test logs. Each has Insert instance layer "VK_LAYER_KHRONOS_validation" 4 times, once per flip test, on main too.
  • Injection logs. The two injection logs (main and head) have it 4 times each. The first-lookup log has it 0 times, because it stops before creating an instance.
  • No missing layer. No log contains was not found but was requested by env var VK_INSTANCE_LAYERS.
  • VUID- lines. 0 on main, 0, 0 and 0 on the three head runs, and 0 in the injection logs.

Host:

  • GPU: AMD Radeon AI PRO R9700 (gfx1201, 1002:7551), driver 32.0.31044.16, Vulkan 1.4.349
  • Validation layer: Khronos validation layer 1.4.363 (LunarG SDK)
  • CPU: Ryzen 9 9950X3D
  • OS: Windows 11 Pro 26300
  • Toolchain: WinLibs GCC 15.2, Release
  • Commits: main c475bd9c77, head 7859c5d74b

AI-assisted: yes

@github-actions

github-actions Bot commented Nov 23, 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 15973 core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
PR 16791 core/libs/prx/libSceVideoOut/include/VideoOutDriver.hpp
core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
PR 17347 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 20315 core/libs/prx/libSceVideoOut/CMakeLists.txt
core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp

@oneandonlydean
oneandonlydean merged commit 80ef8ce into boykopovar:main Nov 24, 2026
14 checks passed
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.

5 participants