fix(menu): the menu's settings and mods.json are on the disk before they replace the old #3022
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3022
Loading…
Reference in a new issue
No description provided.
Delete branch "PedroRossi/Longshot:fix/settings-through-atomic-write"
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?
Summary
host/hos_atomic_file.his the one helper every write of a setting is meant to go through: written beside, flushed tothe disk, moved over the old file, retried while another program holds it. The menu's save of
settings.ini(
vk_menu.cppsave()) and the write ofmods.json(game/mods.cwrite_file) had their own, which never flush:after a power cut or a crash at the wrong moment the new file can be empty or torn with the old one already replaced,
and the settings or the mod order reset.
write_fileis nowhos_atomic_write. The menu's save flushes its file (fsync;_commiton Windows) before themove, and moves it with the helper's
hos_af_move(retried for a second while another program holds the file, thefolder flushed). Its in-place fallback when the move still fails is kept as it was.
Read first:
save()ingpu/vk/vk_menu.cpp,write_fileingame/mods.c.Testing
Tested: in game, Debian 13, GeForce GTX 1660 SUPER, NVIDIA 550.163.01, headless: V-Sync changed over the control bridge; the menu's save wrote the profile's
settings.ini whole with the change, nothing left beside it, exit 0. mods.json is written only from the Mods tab, which
the bridge can't drive: tests/test_mods_list.py builds the real mods.c and calls
hos_mod_edit, throughwrite_fileand so
hos_atomic_write: passes.Checks: the new source checks in test_settings_atomic.py fail on main and pass here. The fixtures that compile these
files build with the helper and pass (test_menu_env_overrides.py, test_mods_size_table.py, test_mods_sizes.py). Four
that cut
save()for other checks already fail on main, for names of their own (i18n,pause_background_now,publish_fps_cap): they get a stand-in that moves assave()did, so they fail only as onmain; with their one missing name stubbed locally, test_menu_save_atomic.py's 10 cases (full disk, a linked file,
read-only folder and file, the file's mode...) pass here as on main. Again on main @
1938a302, the game built through thePC's job queue: V-Sync changed over the control bridge, the game quit and the same profile started again: V-Sync
kept (settings.ini held vsync=2, nothing beside it), exits 0. For Windows with llvm-mingw, the renderer alone
compiled and longshot_vk.dll linked, and the host's C compiled (0 failed);
mise run test(--strict) on main @1938a302, and on main with this change merged (together with #3017, #3018, #3019, #3020, #3021, from the same audit): 775 passed, 145 failed, 10 skipped both ways, so none fails only with it. The 145 are named at the end.Still to test:
frame time around each change as on main (each settings save now flushes the file to the disk before it
replaces the old one)
something the Test Farm plays)
(the Mods tab can't be driven over the control bridge)
Measurements
Nothing to measure in play: a settings save, made only when a setting changes, adds one fsync of the ~4 KB file, 1.25 ms on this PC's NVMe (the median of 40, the slowest 2.0 ms); the Test Farm run asked for in Still to test watches frame time around a change.
Risks
A settings save now waits for the disk: milliseconds on an SSD, more on an SD card. A revert undoes it.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.The 145 checks of
mise run testthat fail on main @1938a302on this PC too, with or without this change97 need a tool this PC doesn't have on PATH (
--strictfails them):48 fail on main itself: test_blocks_at_start.py, test_bug_report.py, test_cloth_kernels.py, test_cloth_loops.py, test_cloth_sphere.py, test_cloth_step12.py, test_cloth_step8.py, test_cloth_step9.py, test_control_picture.py, test_crash_record.py, test_crt_options.py, test_dev_update.py, test_dlssg_pace.py, test_draw_stream_visibility.py, test_framegen_resources.py, test_fsr_uniform_ownership.py, test_game_boundary.py, test_guest_holes.py, test_image_reaper_threads.py, test_image_view_retry.py, test_input_background.py, test_keyboard_option.py, test_linux_pressure.py, test_loaded_modules_drop.py, test_log_levels.py, test_menu_keys.py, test_menu_save_atomic.py, test_mesh_first_types.py, test_oot_occ_raster.py, test_option_ids.py, test_perf_send.py, test_pipeline_tour.py, test_present_acquire_ahead.py, test_present_image_free.py, test_present_source_crop.py, test_program_cache_cleanup.py, test_program_cache_one_variant.py, test_readback_timeout_reuse.py, test_recording_admission.py, test_screensaver.py, test_switch_table.py, test_target_retention.py, test_tex_desc_memo.py, test_thinlto_tls.py, test_upscaler_round_trip.py, test_vram_compact.py, test_windows_display_startup.py, test_windows_on_linux.py
Found in an AI-assisted audit of the repository. The test, the fix, the runs and this description were made with Claude Code; I reviewed them.
Co-Authored-By: Claude Opus 5.5 [email protected]
🤖 Generated with Claude Code
Tested in game: Debian 13, GeForce GTX 1660 SUPER, NVIDIA 550.163.01, headless: V-Sync changed over the control bridge (the menu's save), the game quit and the same profile started again: V-Sync kept, settings.ini whole with nothing beside it; exits 0
PedroRossi referenced this pull request2026-12-02 17:54:18 +00:00
WIP: fix(menu): the menu's settings and mods.json are on the disk before they replace the oldto fix(menu): the menu's settings and mods.json are on the disk before they replace the oldPossibly related, for context:
@Beanstalk Windows and the Steam Deck: change a few settings in the Insert menu during play (V-Sync, the frame rate cap), and compare frame time around each change with main. Each settings save now flushes the file to the disk before it replaces the old one.
@PedroRossi only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.Mod support has been completely rebuild, please see if this is still applicable to the
mod-apibranch and re-open!Pull request closed