feat(libc): rotate ANYPS5_LOG_FILE by size and add an optional frame hang watchdog #17259

Open
MarcZX10 wants to merge 33 commits from upstream-pr/17259 into main
MarcZX10 commented 2026-11-08 16:30:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-08T16:30:13Z.


What

  • ANYPS5_LOG_FILE rotates by size. ANYPS5_LOG_MAX_BYTES sets the size limit and ANYPS5_LOG_KEEP sets how many rotated files are kept. Without a limit the file grows as before.
  • An optional frame hang watchdog in libSceVideoOut, controlled by ANYPS5_HANG_SECONDS. It is off by default (unset, empty or 0). When set, it reports once per hang when no frame has been presented for that many seconds, and reports again only after a new frame arrives and a later hang happens.
  • Documentation: the variables in docs/dev/ENVIRONMENT.md and docs/user/USAGE.md, and the known gaps in docs/dev/debt/libc.md and docs/dev/debt/libSceVideoOut.md.

Tested

Linux, archive build of this head, focused targets only:

run_tests.sh '^(log_file|log_macros|log_macros_timestamps|video_out_frame_watchdog|video_out_telemetry)$' log_file_tests log_macros_tests video_out_frame_watchdog_tests video_out_telemetry_tests
BUILD-EXIT 0
1/5 Test #1133: log_macros .......................   Passed    0.02 sec
2/5 Test #1134: log_macros_timestamps ............   Passed    0.01 sec
3/5 Test #1135: log_file .........................   Passed    0.27 sec
4/5 Test #3853: video_out_telemetry ..............   Passed    0.62 sec
5/5 Test #3855: video_out_frame_watchdog .........   Passed    1.53 sec
100% tests passed, 0 tests failed out of 5

Not verified: rotation on Windows and macOS (only the Linux file path ran), a real hung title (the watchdog was only run through its unit test and the window start and stop), real shader compile times (not measured).

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, no GPU run; the VideoOut watchdog was only exercised by its unit test
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5213029211 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17259). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-08T16:30:13Z. --- ### What - `ANYPS5_LOG_FILE` rotates by size. `ANYPS5_LOG_MAX_BYTES` sets the size limit and `ANYPS5_LOG_KEEP` sets how many rotated files are kept. Without a limit the file grows as before. - An optional frame hang watchdog in libSceVideoOut, controlled by `ANYPS5_HANG_SECONDS`. It is off by default (unset, empty or `0`). When set, it reports once per hang when no frame has been presented for that many seconds, and reports again only after a new frame arrives and a later hang happens. - Documentation: the variables in `docs/dev/ENVIRONMENT.md` and `docs/user/USAGE.md`, and the known gaps in `docs/dev/debt/libc.md` and `docs/dev/debt/libSceVideoOut.md`. ### Tested Linux, archive build of this head, focused targets only: ``` run_tests.sh '^(log_file|log_macros|log_macros_timestamps|video_out_frame_watchdog|video_out_telemetry)$' log_file_tests log_macros_tests video_out_frame_watchdog_tests video_out_telemetry_tests ``` ``` BUILD-EXIT 0 1/5 Test #1133: log_macros ....................... Passed 0.02 sec 2/5 Test #1134: log_macros_timestamps ............ Passed 0.01 sec 3/5 Test #1135: log_file ......................... Passed 0.27 sec 4/5 Test #3853: video_out_telemetry .............. Passed 0.62 sec 5/5 Test #3855: video_out_frame_watchdog ......... Passed 1.53 sec 100% tests passed, 0 tests failed out of 5 ``` Not verified: rotation on Windows and macOS (only the Linux file path ran), a real hung title (the watchdog was only run through its unit test and the window start and stop), real shader compile times (not measured). ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a, no GPU run; the VideoOut watchdog was only exercised by its unit test - [x] AI-assisted: yes
adriadam10 commented 2026-11-12 14:59:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-12T14:59:49Z.

Review: CHANGES_REQUESTED


Agreeing with @oneandonlydean's point, which is still open on the current head:

  • core/libs/prx/libc/src/LogFile.cpp:74-81 (Tee::rotate): the results of RemoveFile(_path) (keep 0) and RenameFile(_path, RotatedName(_path, 1)) are ignored. If the rename fails (on Windows, another process holds the log without FILE_SHARE_DELETE), the same full file is reopened, every later write rotates again, the oldest rotated files are deleted and shifted away, and the live file grows past the limit. Please check that result and, on failure, write one notice to the terminal, turn rotation off for the rest of the run and keep appending.
  • Add a test that makes the rename fail (for example keep 1 with a directory at path.1) and checks the file keeps growing, rotated files stay intact and the notice is written once.

The branch also conflicts with main now; rebase when you push the fix. The rest (default path, watchdog, docs, Windows link fix) looks fine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5876642046 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17259#pullrequestreview-5876642046). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-12T14:59:49Z. **Review:** CHANGES_REQUESTED --- Agreeing with @oneandonlydean's point, which is still open on the current head: - `core/libs/prx/libc/src/LogFile.cpp:74-81` (`Tee::rotate`): the results of `RemoveFile(_path)` (keep 0) and `RenameFile(_path, RotatedName(_path, 1))` are ignored. If the rename fails (on Windows, another process holds the log without `FILE_SHARE_DELETE`), the same full file is reopened, every later write rotates again, the oldest rotated files are deleted and shifted away, and the live file grows past the limit. Please check that result and, on failure, write one notice to the terminal, turn rotation off for the rest of the run and keep appending. - Add a test that makes the rename fail (for example keep 1 with a directory at `path.1`) and checks the file keeps growing, rotated files stay intact and the notice is written once. The branch also conflicts with `main` now; rebase when you push the fix. The rest (default path, watchdog, docs, Windows link fix) looks fine.
ligmaSec commented 2026-12-03 16:28:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:28:09Z.

Review: COMMENTED


The watchdog can report a completed presentation before the first frame. DisplayWindow::Ensure calls StartFromEnvironment immediately after creating the window, and Start calls Beat. If the first draw or shader compile exceeds the threshold, the warning says the last stage was “frame presented to the window” even though no presentation occurred. Please track the startup timer separately from the first presentation, and cover that case in the watchdog test.

The full log_file fixture and all three EOP flip cases passed on main at 9d362fb088 and on 0073d330e4 under Xvfb on Linux with Mesa lavapipe. The VideoOut tests required Vulkan and disabled the shader cache. The loader inserted VK_LAYER_KHRONOS_validation 1.4.369 in both paired logs. There were no missing-layer warnings or VUID- messages. The branch's video_out_frame_watchdog also passed. The earlier abrupt-child failure in the isolated rotation harness did not occur in the integrated log_file test.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6173925064 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17259#pullrequestreview-6173925064). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T16:28:09Z. **Review:** COMMENTED --- The watchdog can report a completed presentation before the first frame. `DisplayWindow::Ensure` calls `StartFromEnvironment` immediately after creating the window, and `Start` calls `Beat`. If the first draw or shader compile exceeds the threshold, the warning says the last stage was “frame presented to the window” even though no presentation occurred. Please track the startup timer separately from the first presentation, and cover that case in the watchdog test. The full `log_file` fixture and all three EOP flip cases passed on `main` at `9d362fb088` and on `0073d330e4` under Xvfb on Linux with Mesa lavapipe. The VideoOut tests required Vulkan and disabled the shader cache. The loader inserted `VK_LAYER_KHRONOS_validation` 1.4.369 in both paired logs. There were no missing-layer warnings or `VUID-` messages. The branch's `video_out_frame_watchdog` also passed. The earlier abrupt-child failure in the isolated rotation harness did not occur in the integrated `log_file` test. AI-assisted: yes.
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/17259:upstream-pr/17259'
git switch 'upstream-pr/17259'

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