fix(prompts): the hint bars on screen take a change of the prompts at once #2756
Open
github-sync
wants to merge 5 commits from
github/pr/2756 into main
pull from: github/pr/2756
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2756
Loading…
Reference in a new issue
No description provided.
Delete branch "github/pr/2756"
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?
A change of Button prompts or of the controls while the game runs (#2366, #2435) reached every text shown after it, but the hint bars already on screen kept their old icons until they were shown again: the ocarina's bar ("Check songbook", "Play a note", "Cancel") while the ocarina is out, the pause menu's ("Rotate", "Select", "Back"), the songbook's ("Check song", "Listen to the melody").
Why
Each icon in those bars is a text box of its own with one code (the ocarina's bar:
e046,e044,e045,e043,e042,e040,e041). The game lays each out and draws it once, when the bar appears, and doesn't callf_8152aec0orf_8152b670for it again while the bar stays, sotext_rewritenever ran on them.Marking them to be laid out again isn't enough on its own. Their pictures are made by another thread (
UpdateTextBoxTextureThread, the box's+380bit 2), which the new layout doesn't ask for a new picture. With the codes rewritten and no new picture, the icons came out blank: the new codes' glyphs were never rasterized. (Found with a log of the guest call chain atft_smooth_render: the bars' glyphs are drawn from0x834a2ec8 → f_80df2680 → f_80e6dfe0 → f_80e6e0e0, other boxes' fromf_8152b670 → f_80e6e0e0.)What it does (
host/prompts.c)shown_keep(in the layout hook): keeps the boxes with button codes the layout has seen (up to 256), with their first word, text pointer and length.shown_mark(when the font changes,live_font): each kept box that is still the one seen gets the status bitshos_prompts_text_drawsets (0x20000 | 0x100000). Its next layout rewrites its codes on the game's own thread, as any box's. A box no longer the one seen (freed, or another text) is let go and never written.shown_picture(in the draw hook): a box marked and laid out again, whose picture another thread makes, has its picture made at that draw. It callsf_80e6e0e0(box, the draw's two words at +24), the callf_8152b670makes for the boxes whose picture it makes itself. The game's context is mid-call, so the call goes throughhos_call_guest_kept(new inhost/hos_hostcall.c, besidehos_call_guest), which puts every register (x0..x30, the vector registers, NZCV) back as it was;hos_guest_xreads the draw's x2. Boxes the draw renders itself are left to it.prompts.cstays free ofCtx:tests/test_mods_size_table.pybuilds it with ahos.hof its own, and stubs the two new calls as it doeshos_regions.f_80e6e0e0(inf_80e6dfe0, its job) goes throughhos_text_picture_thread(nx2/oot_patches.pypatch_text_picture,host/hos_hostcall.c), which holds an SRW lock;shown_picturetakes the same lock for its call. The game takes no lock around that call on either side, so without it the thread could make a box's picture whileshown_picturemade it too. The draw's own calls are left unlocked.The bar's spacing (the layouts' part) is the bar's as it was made: after Keyboard → Xbox with the ocarina out, Xbox's wider LB/RB sit closer than at a fresh start until the bar is shown again. The icons are right; moving panes already made is a further step.
Screenshots
Each bar while it stays on screen, with Button prompts switched live. "Before" is main with #2755's notes, "after" this branch. The "before" runs had the default keys, the "after" runs the tester's own, so the keys differ; what matters is whether a bar follows the switch.
Testing
In game, native Windows 11, RTX 5060 Ti, the v131072 game, a build of this branch on main (
4678050), driven with the control bridge (headless), a save in the Fire Temple:prompts: now the xbox icons in texts, 16 buttons on these controls; 10 texts on screen laid out againTests:
test_prompts_live,test_prompt_font_bind,test_prompt_auto_face,test_menu_hooks,test_prompt_skippass here;test_mods_size_table's folder part runs on Linux only (CI). After moving the guest call tohos_hostcall.cthe game was built again (v2.1.0-rc.3-260, main51da046with both PRs) and the same run repeated: every bar follows Keyboard → Xbox → Keyboard as before,10 texts on screen laid out again, the game plays on after the pause menu.The branch is rebased on main (
51da046) after the run; the files it touches didn't change there, and the tests above pass on it again. A row for the run is indocs/tested-configurations.md.It's independent of the keyboard notes PR (each applies to main alone); the run above had both.
🤖 Generated with Claude Code
I merged this into current main, together with #2755. tests/test_mods_size_table.py (including the folder part on Linux), test_prompts_live, test_prompt_font_bind and test_menu_hooks all pass. The only conflict with #2755 is the tested-configurations row.
The marking half (shown_keep/shown_mark) is careful: a box is matched by vtable, text pointer and length before its status word is touched. The part I'd like a maintainer to weigh is shown_picture (host/prompts.c:1141). From the draw thread, it calls f_80e6e0e0 on boxes whose +380 bit 2 says UpdateTextBoxTextureThread owns their picture. Nothing stops that thread from rasterizing the same box at the same moment, and f_80e6e0e0 may rely on locks that f_8152b670 takes before its own call. Restoring registers covers neither case. A race there would show up as a rare crash in FreeType or the upload, so one clean run doesn't rule it out.
Could you check whether f_80e6e0e0 or its caller takes a lock or a per-box flag? The other option is to set whatever bit makes the texture thread redo the picture itself.
Thanks, both points checked in the lifted code.
A lock on the caller's side: none.
f_8152b670callsf_80e6e0e0for the boxes whose picture it makes itself (+380bit 2 clear) right after loading[x2+24]/[x2+32], with no lock or per-box flag taken before (the only state it touches is+384bit 16, set after the call). Sof_80e6e0e0doesn't rely on a lock its caller holds, and the game already runs it on the draw thread whileUpdateTextBoxTextureThreadmakes other boxes' pictures.The same box at once: a real gap, now closed. The texture thread's job (
f_80e6dfd0→f_80e6dfe0: the message is the job, its count at+0, the boxes at+8,SignalLightEventon+48when done) callsf_80e6e0e0for each box with no lock either, so nothing in the game kept it off a boxshown_picturewas making.The fix in
5eae6a5: one picture of a box at a time.nx2/oot_patches.pypatch_text_picturesends the texture thread's call (0x80e6e0a0inf_80e6dfe0) throughhos_text_picture_thread(host/hos_hostcall.c), which holds an SRW lock around it.shown_picturetakes the same lock around its own call.I tried your other route first, the texture thread making the picture again itself: after the relayout, clearing
+384bit 16 (the "picture made" flagf_8152d9a0sets for those boxes), and also setting status bit 23 (whatf_8152d9e0checks) both left the bar blank. The trigger must be in the job's producer, which I didn't find in reasonable time; the lock covers the race without it.Tested on Windows 11, RTX 5060 Ti, a build of this branch (main
51da046), the Fire Temple save, headless through the control bridge: the ocarina bar Keyboard → Xbox → Keyboard as before, then 12 more switches 20 frames apart with the ocarina out, no fault.test_menu_hooksnow checks the new patch (once, declared, a lift patched again left alone, a file without the call untouched),test_mods_size_tablestubs the lock, and the 19 checks that readoot_patches.pyorhos_hostcall.cpass here, withtest_prompts_live,test_prompt_font_bind,test_prompt_auto_faceandtest_prompt_skip.🤖 Generated with Claude Code