Skip to content

fix(trace): preserve Unicode output paths on Windows - #7599

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
THEMANnt:fix/trace-unicode-paths
Nov 8, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
THEMANnt:fix/trace-unicode-paths

Conversation

@THEMANnt

@THEMANnt THEMANnt commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

On Windows, setting APS5_TRACE_DIR to a directory containing characters such as ™ or Japanese text can throw filesystem error: Cannot convert character sequence: Illegal byte sequence when trace output is initialized. The narrow environment-variable value is passed through a locale-dependent filesystem conversion.

Read this path with _wgetenv on Windows and construct it from the native wide string. Put the shared directory selection in TraceFile::Directory, used by both interval summaries and captured traces. POSIX continues to use getenv; an unset variable still selects ..

The Windows regression checks unset and ASCII settings, preserves a Unicode path, and writes both gzip trace and JSONL summary files there. No title-specific handling is added.

Tested

Current revision 4593f50e7, rebased onto upstream main db73af350, Windows 11 Pro build 26200, supported MinGW-w64 GCC 15.2, Release:

  • agc_performance_trace and agc_profile_output: both build and pass on this branch, including the Unicode directory regression. Conventions against target upstream/main and whitespace pass.
  • The required conventions run against stale fork origin/main reports the pre-existing APS5_CPU_FLIP_IN_ORDER environment-documentation error and upstream debt warnings; none of that code is changed here.
  • Reproduced the feat(trace): record host, title and per-frame benchmark data #7080 test-file merge conflict, then separated the new standard-library includes and the Directory() call from its benchmark additions. The Unicode test body and production fix are unchanged by this follow-up.
  • Fresh changed-file audit of all 694 open PRs found only feat(trace): record host, title and per-frame benchmark data #7080 sharing these files (excluding this PR itself). This branch adds no files or exports. The unchanged tools/pr_overlap.py --branch fix/trace-unicode-paths, using authenticated API transport and that exhaustive candidate set, reports No overlap with open pull requests.
  • This branch merges cleanly with feat(trace): record host, title and per-frame benchmark data #7080 head 88f818410218ca4aa117d850354a50f0a1fe4b62. A separate local integration build succeeds; agc_profile_output and param_json_parser pass. Its expanded agc_performance_trace test fails with St13__ios_failure ... has no unwind data. A control containing main + feat(trace): record host, title and per-frame benchmark data #7080 without this PR reproduces the same failure. The combined suite is therefore not claimed green; that exception-handling failure is separate from this branch's resolved merge overlap.

Earlier validation at d7738226d remains applicable to the unchanged Unicode fix: the narrow-conversion negative control fails; the wide-path test passed five repeated runs; the runtime libs target and four focused trace/registration tests built and passed. An independent Windows/Linux validation is recorded in wachi35676's comment. Full runtime libraries, registration GPU tests and Linux/macOS were not rerun for this test-layout-only follow-up. No performance claim.

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: NVIDIA GeForce RTX 5070 Ti, driver 616.92, Windows 11 Pro build 26200
  • AI-assisted: yes (OpenAI Codex; reviewed and tested locally)

@github-actions github-actions Bot added the agc libSceAgc* label Oct 18, 2026
@wachi35676

Copy link
Copy Markdown
Contributor

Checked at d7738226d with the variable inherited from the parent process rather than set in-process (PowerShell, ACP 1252, the same libstdc++). Comparing getenv→path with this PR's _wgetenv→path:

  • ASCII: both work.
  • café, tm™ (in cp1252): the narrow form throws Cannot convert character sequence: Illegal byte sequence.
  • 日本語, жу, emoji😀 (not in cp1252; the last is a surrogate pair): getenv returns ?, and the narrow form fails with cannot create directories: Invalid argument [...\???].

_wgetenv creates the right directory and writes the file in all six cases.

Tests:

  • agc_performance_trace, agc_profile_output and both agc_driver_registration_trace tests pass on Windows (GCC 15.2).
  • With the narrow getenv put back into TraceFile::Directory, agc_performance_trace fails with the conversion error.
  • On Linux (gcc 13.3), agc_performance_trace and agc_profile_output pass.

The same narrow getenv→path pattern exists for APS5_DUMP_SUBMITS in SubmissionCapture.cpp:104, if a follow-up is wanted.

AI-assisted: yes (Claude Code); results above were run on this machine.

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

The Windows path is read as wide text and kept in std::filesystem::path without a locale-dependent narrow conversion; the POSIX path remains unchanged. The new test covers unset, ASCII and Unicode values and verifies both summary and gzip output. The reported Windows negative control and independent cross-platform test results support the fix; the current conventions, eligibility and report checks pass. I also reran tools/pr_overlap.py against the current open PR queue (1,105 PRs), and it reports no overlap. I did not run the product tests locally. No blocking issue found; approved.

@JJenkx

JJenkx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Independent Windows run, as data only. Machine: Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Release. Head 4593f50 was merged onto main b7d1d47 (together with #8726, which touches other files). agc_performance_trace passes in 5 of 5 runs.

AI-assisted (Claude Code).

@blawesom

blawesom commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Static review plus an independent Linux run on both trees per the repo AGENTS AGC-adjacent protocol (CachyOS, kernel 7.2.10, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, Ryzen 7 9800X3D). No findings.

What I checked

  • The fix is exactly the narrow, boring shape it should be: a TraceFile::Directory() helper that reads APS5_TRACE_DIR on the wide API under _WIN32 (_wgetenv → std::filesystem::path(wstring)) instead of getenv, which would mangle non-ANSI characters in a Windows trace path. PerformanceTrace.cpp's local traceDirectory() forwards to it — no behavior change elsewhere, the default "." path is preserved verbatim.
  • The test (Directory()) pins the actual regression class: sets APS5_TRACE_DIR to a Unicode string (\u2122\u65e5\u672c\u8a9e) under _WIN32, asserts Directory() round-trips and actually writes AppendLine/WriteGzip output into that path. ASCII and empty/default cases are pinned too (no silent behavior change on non-Windows where the test compiles as a no-op narrower check).
  • This is a Windows-only behavior change (the #ifdef branch) with a matching Windows-only test guard — safe on other hosts.

Focused paired run (VVL env; logs captured both trees)

tree agc_performance_trace VUID- missing-layer
this head 4593f50e71 Passed (0.00s) 0 0
main bb04a4f1ea Passed (0.01s) 0 0

Both logs checked: 0 was not found but was requested by env var VK_INSTANCE_LAYERS, 0 VUID-. Comparing logs, no new errors introduced. This path is trace I/O (not shader/AGC rendering) so the env pair is a cheap sanity check, not a strict AGENTS requirement — running it regardless since it's an AGC-directory code path.

Not covered

The Unicode path fix is Windows-only at runtime; I can't exercise _wputenv_s/_wgetenv from Linux — that branch compiles correct-by-inspection but is untested here. Worth confirming on a Windows host/CI before merge if that's cheap.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 4593f50 merged onto main ba5b533 · tested 2026-10-29 18:27 UTC · 23 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,211 passed · 5 failed (0 new, 5 also fail on main) · 39 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 2,255 of 2,891 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 (856 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) none
Failing on main too (5, not counted against this PR)
agc_compute_pipeline_inspection
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (4 IDs in 405 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (405 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_alpha_to_coverage, agc_driver_array_layer_target_cpu, agc_driver_bc_block_copy, and 397 more
VUID-vkCmdCopyImage-srcImage-01548 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-vkCmdCopyImage-srcImage-01551 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (39)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_msaa_dcc_compared_import_2: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_4: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_8: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_stencil_ref_export: skipped, the device lacks VK_EXT_shader_stencil_export
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_main: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_fresh: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_labels: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SD
Reproduce
git fetch origin 4593f50e71c4bdcea0038165a608bd288befee70 ba5b5330b37724bca4b99f30faab504653635a04
git checkout ba5b5330b37724bca4b99f30faab504653635a04 && git merge --no-ff 4593f50e71c4bdcea0038165a608bd288befee70
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 32 --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 4 --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 NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@github-actions

github-actions Bot commented Oct 29, 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 14982 core/libs/prx/libSceAgcDriver/Execution/src/TraceFile.cpp L5-6, L16

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 12828 core/libs/prx/libSceAgcDriver/Execution/src/PerformanceTrace.cpp
PR 13809 core/libs/prx/libSceAgcDriver/Execution/src/PerformanceTrace.cpp
core/libs/prx/libSceAgcDriver/tests/PerformanceTrace.cpp

@THEMANnt

THEMANnt commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@adriadam10 Could you take a look at this PR when convenient? It remains mergeable, has an approval, and has independent Windows/Linux validation.

The overlap bot now flags #14982 and shared code with #12828. Is coordination with either PR needed before merging, or is there another outstanding requirement I should address?

@BunnyFl

BunnyFl commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

@THEMANnt a heads-up on an overlap, with nothing asked of this PR as it stands.

#14982, which replaces the stream-exception handling in the AGC and VideoOut file writers with explicit stream-state checks, edits the same two regions of TraceFile.cpp this PR does:

#14982 also narrows the catch in ReplaceGzipFile and drops its #ifndef _WIN32 guards, in a different part of tests/PerformanceTrace.cpp from the Directory() case added here.

Neither change contradicts the other. Whichever lands second needs a two-hunk rebase in TraceFile.cpp.

The overlap table on #14982 lists this PR as a line conflict, with the files and lines; gh pr view reports both as MERGEABLE against main right now.

@adriadam10
adriadam10 merged commit 4ab649f into boykopovar:main Nov 8, 2026
12 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the diff: TraceFile::Directory reads APS5_TRACE_DIR through _wgetenv on Windows and getenv elsewhere, and both the interval summaries and the captured traces use it. The new Directory() test (Windows only) covers unset, ASCII and a Unicode path, and writes both the jsonl and gzip files there; it also matches wachi35676's independent check. Merged.

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

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants