lifecycle: subclass the title window in its own character set (LIFECYCLE-ANSI-SUBCLASS) #2344
Closed
leonida/mandy
syfyra wants to merge 0 commits from
fix/lifecycle-ansi-subclass into main
pull from: fix/lifecycle-ansi-subclass
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!2344
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/lifecycle-ansi-subclass"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claimed in the coordination issue as: LIFECYCLE-ANSI-SUBCLASS
What and why
runtime/shims/lifecycle.cppsubclasses the title's first top-level window soSC_CLOSEruns the suspend callbacks. It always did so withGetWindowLongPtrW/SetWindowLongPtrW. The retail title creates its window withCreateWindowExA(its import table names it from the-ansi-window set), which makes an ANSI window when the class was registered with the A function too; the title's class registration is not recorded indocs/, so whether the retail window is ANSI is not measured here. Setting a W procedure on an ANSI window turns it into a Unicode window:IsWindowUnicodebecomesTRUE, and every text message the title posts and dispatches with the A functions is converted to Unicode for the hook.CallWindowProcWthen converts it back for the title's ANSI procedure.With a single-byte code page the round trip is lossless. With UTF-8 as the ANSI code page it is not. That is the code page of Windows' "Beta: Use Unicode UTF-8 for worldwide language support" option, or of a process whose manifest asks for it. Measured on Windows 11 with a small probe, an ANSI window with
PostMessageA(WM_CHAR, byte)for each byte of "é€" (C3 A9 E2 82 AC), thenDispatchMessageA:c3 a9 e2 82 acSetWindowLongPtrW(main)83 c3 a9 c2 a2 c3 80 e2 ac c2SetWindowLongPtrA(this change)c3 a9 e2 82 acWith code page 1252 all three receive the bytes unchanged. Only
IsWindowUnicodediffers there.The hook now reads and sets the window procedure in the window's own character set (
IsWindowUnicode), with an A and a W variant of the procedure that call the title's withCallWindowProcA/CallWindowProcWand fall back toDefWindowProcA/DefWindowProcW. A Unicode window is hooked as before.Tested
Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo:
lifecycle_testgets a section 5. An ANSI class's window is created through theCreateWindowExAshim, and the test checks that it is hooked, that it stays an ANSI window, that the fiveWM_CHARcodes reach its procedure unchanged and in order, and thatWM_SETTEXT/WM_GETTEXTstill forward. A further check confirms a Unicode title window stays Unicode.main: 1 of 35 checks fails (the window becomes Unicode).lifecycle_utf8_test(MSVC only): the same source withtest/utf8_codepage.manifestembedded (activeCodePageUTF-8), plus a check thatGetACP()is 65001.main: 2 of 36 checks fail; the title's procedure receives83 c3 a9 c2 a2 c3 80 e2 ac c2.ctest -j 8over the 170 CPU tests (no Vulkan SDK here): all pass.runtime/CMakeLists.txt,runtime/shims/lifecycle.cpporruntime/test/lifecycle_test.cpp, including #2054.scripts/check_no_game_data.pyon the four files.Not tested under Wine, where the manifest test may need Wine's own
activeCodePagesupport.GPUs tested: n/a (CPU tests)
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Independent verification on this machine (Windows 11, MSVC 19.44.35226): the test this branch adds is registered with no command, so
ctestreports it as "Not Run" - and it turns a two-test target into a red one.1. It applies and builds.
merge-treeclean ontomaind367675c7;lifecycle_testlinks ([3/3] Linking CXX executable lifecycle_test.exe, built at 12:09:30 during this run - the binary is not stale).2. Running the target's two tests:
3. Why, from
ctest --show-only=json-v1:lifecycle_utf8is the test this pull request adds, and itscommandis empty, so CTest has a test with nothing to run.lifecycle- the pre-existing one - resolves normally and passes.4. This is the fourth pull request in the queue with the same defect, and
mainhas none of them in its 546 tests:vk_sparse_queue_orderwin32_env,win32_env_overrided3d12_skip_compute_{unset,one,all}lifecycle_utf8The cost in each case is the same and double: the test never runs, and
ctestcountsNot Runas a failure - so the branch turns the suite red while testing nothing.The likely fix, and it is one line:
add_test(NAME lifecycle_utf8 COMMAND lifecycle_test …)resolves only iflifecycle_testis visible in the same directory scope at that point;$<TARGET_FILE:lifecycle_test>always resolves, and so does moving theadd_testnext to itsadd_executable.What I did not test: whether the UTF-8 case itself passes once it runs - that needs the registration fixed first, and I did not add it locally to find out, because the fix belongs to the author.
Why I am commenting: I verify open pull requests that replay onto current
main, build the binaries their tests name, and run them. ANot Runis the one result that looks like a failure and is really an unfinished registration.Written with an AI assistant.
Follow-up with the extra evidence, because the cause is not what I first implied: the target exists, builds, and the registration is shaped exactly like its working sibling.
So
$<TARGET_FILE:…>would fix the symptom, and so would whatever makes the sibling work - but the sibling is not different in the way I assumed. Here is the whole structural difference, side by side:The only difference I can find is that
lifecycle_utf8_testis created insideif(MSVC)while itsadd_testsits outside that block. Both guards pass on this machine (MSVC 19.44.35226), the target exists and links, and the manifest it references (test/utf8_codepage.manifest) is present.I am not going to assert that the
if(MSVC)is the cause - I could not reproduce a minimal case for it, and CMake's target scoping inadd_testis not something I want to guess about. What is proven: target builds, file exists, guard passes, and CTest still has the test with no command. What would settle it in one edit: move theadd_test(NAME lifecycle_utf8 …)inside theif(MSVC)block, or use$<TARGET_FILE:lifecycle_utf8_test>; either change is one line and the author can test both.Why this matters beyond this pull request: four pull requests in the queue have a test with an empty command (#1182, #1242, #1419, #2344) and
mainhas none. If theif()placement is the shared cause, one contiguous edit fixes all four - and if it is not, knowing that saves the next person from trying it.Written with an AI assistant.
I tested both fixes on this machine, and both make the command resolve. Here are the results, so the author does not have to run the experiment.
Baseline (the branch as it is):
Variant 1 - generator expression, nothing moved:
Variant 2 - move the
add_testinside the block that creates the executable:So the cause is the placement relative to the conditional: the same
add_testline, with the same target name, resolves once it is inside the block that created the target, and does not resolve when it is 1400 lines below it and outside that block. Variant 2 is the more informative of the two: it shows the target name alone is enough when the registration sits in the same scope, which is what I could not establish by reading.What I did not do: decide which variant the author should take. Variant 1 is the smaller diff and cannot be affected by scope at all; variant 2 keeps the file's existing style (every other test registers where its executable is defined, as far as the blocks I looked at).
And the part that may help the other three: #1182, #1242 and #1419 have the same symptom - a test with an empty command,
mainhas none. If theiradd_testlines are also separated from theiradd_executableby a conditional, one contiguous edit fixes all four. I have not checked those three blocks, so treat that as the next thing to look at rather than a conclusion.How this was measured: applied the branch to
maind367675c7, made one edit, re-rancmake -S runtime -B …, readctest --show-only=json-v1, reverted the edit. Nothing was pushed - both edits were local to a scratch worktree.Written with an AI assistant.
Correction, and it retracts the defect:
lifecycle_utf8is not registered with an empty command. The empty command came from reading the manifest before building that executable.The mechanism, measured here:
add_test(NAME lifecycle_utf8 COMMAND lifecycle_utf8_test)writes the target name into the test file; CTest substitutes the executable's path only once that executable exists. When I read the manifest I had builtlifecycle_test(because I was chasing the sibling) and notlifecycle_utf8_test- which is exactly why one resolved and the other did not.And my two "fixes" were not fixes:
$<TARGET_FILE:…>resolves at configure time into a literal path, so it bypasses the build state; moving theadd_testinsideif(MSVC)changed which configure I compared against, not the cause. Both made the empty value go away without touching anything real - which should have made me suspicious, and did not.So the whole "empty command" family was mine: four pull requests (#1182, #1242, #1419, #2344) reported with a defect none of them has. Two were withdrawn earlier today for a stale manifest; the other two are withdrawn now.
What the correct method is, and it is embarrassingly simple: build the test's target first, then read the manifest.
What still stands for this pull request: it applies to
maind367675c7,lifecycle_testandlifecycle_utf8_testboth build, and with both built the tests resolve - I will re-run the pair and report the result rather than the registration.Written with an AI assistant.
After withdrawing my registration claim, here is the verification that one was standing in for: the change is covered by its own tests, and the control bites on both.
1. It applies and builds.
merge-treeclean ontomaind367675c7. Two executables built for this run:2. With the branch, both tests pass:
lifecycle_utf8runs - the "Not Run" I reported earlier was the manifest read before this binary existed, and I have retracted it above.3. The control - revert only the shim, keep both tests, rebuild both:
Both executables fail, with the same sentence, and that sentence is the change: a window the title hooked as ANSI must stay an ANSI window - the branch's subclassing keeps that property,
main's lets it flip. The fact that the identical assertion fails in both the ANSI and the UTF-8 process is the point of the second executable: the same code path, a different active code page.What I did not test: the other lifecycle paths the shim covers (
RegisterAppStateChangeNotification, oversized-window fitting), and the GPU-side title behaviour.Summary for this pull request, after the retraction:
maind367675c7Written with an AI assistant.
Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.
(AI-assisted triage.)
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.