fix(mods): raise the size table entries of the files inside the packs mods serve #3172
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3172
Loading…
Reference in a new issue
No description provided.
Delete branch "snaildev99/Longshot:mods/pack-member-sizes"
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
The game loads each file inside a pack (
Pack/Actor/*.pack.zsand the like) as a resource of its own, with memorysized by that file's own entry in the resource size table, and the game's entries leave little room to spare. The
size table step on
mainsizes the files mods serve, and a pack as a whole, but not the files inside a pack. So a modthat grows a file inside a pack, and ships no size table (or one made for an older version of the mod), loads that file
with too little room for what the game builds from it, and the game sits at a loading screen for ever (Character
Select once hit this with the adult player's animation parameters).
With this change, at each start every pack a mod serves (and every pack the archive merge makes) is compared with the
game's copy, and the entry of each member that grew, or that the game's pack does not have, is raised before the
table is written: a grown member by the same rule as a loose file (with
main's room for BYML lists), a new one byestimate. A pack that does not decode keeps the game's entries and is named in the log, with which copy failed.
How to see it on
main:a_grown_pack_member_is_raised_and_the_others_are_not(content'srestbltests) grows amember from 152 to 304 bytes; on
mainits entry stays the game's 5352, here it is raised to 10720.This is the Rust port of #942.
Read first:
game/crates/content/src/restbl.rs(fit,raise_pack,raise_members), thenlayers.rs(
Builder::fit_sizes, the summary line).Testing
Tested: Windows 11 Pro, RTX 3090, NVIDIA 610.88, in the game, built by
longshot-builder play --profilewiththis PR and the other mod compatibility ports merged, then the same profile on
main. Two test mods made on this PCfrom the game's own
Pack/Actor/Land_LonLon_WheelTrack_A_05.pack.zs(kept local), each with a different file insidethe pack grown by 64 KiB, and no size table. At the start the log says:
resource size table: Actor/Land_LonLon_WheelTrack_A_05.engine__actor__ActorParam.bgyml in Pack/Actor/Land_LonLon_WheelTrack_A_05.pack.zs (merged): entry 6456 -> 534848,the same for
Component/ModelInfo/...ModelInfo.bgyml(5352 -> 2312928), and... 2 for the members of 1 packs.On
mainthe summary line has no member entries and the two files keep the game's. The game then played inKakariko and Hyrule Field. A load that reads the grown files was not reached (the pack's actor is not in those
maps): that is the hand test below.
After the rebase onto
main@3a0f7d8f7, the same profile again, built with this PR @f0c6de6acand the otherports merged (929bf025a): the same two entries (
6456 -> 534848,5352 -> 2312928) and2 for the members of 1 packs.Game-free: the
restbltests below.mise run test, run locally while CI's run waits for approval (Windows 11,tests/run_all.py --strict, 12 checks atonce), here @
f0c6de6acand onmain@3a0f7d8f7: 847 passed, 12 failed, 52 skipped here; 845 passed, 14 failed, 52skipped on
main. All 12 also fail onmain: test_dlssg, test_fsr4_tune, test_lifter, test_no_game_title,test_no_map_reload, test_present_acquire_ahead, test_present_geometry_trace, test_present_held_image,
test_present_image_free, test_sync_watch_event, test_turf_budget, test_ui_renderer.
Still to test:
parameters), played as adult Link through a load, expecting the area to load (by hand)
main(measurement, the review's L4)Measurements
Verdict: Fixed in the size table: a grown file inside a served pack gets a larger entry, in the tests and at
the game's start, where
mainkeeps the game's. The start's size table step takes about 2 ms more with one servedpack (median 30 ms against 28).
Setup:
cargo test -p contenton Windows 11, after the rebase ontomain@3a0f7d8f7: the before side is the testcommit (
b9e06c3ef), which is thatmain's code with the test, and the after side is this PR @f0c6de6ac. Then the test profile above in the game, Windows 11 Pro, RTX 3090; the game's After column is thebuild with the other mod compatibility ports merged (72d64e92f), which holds this PR's commits.
The two in-game rows were measured before the rebase, on
main@f577a1aeaand this PR @4a279a16f; the summaryline is the same after it (Tested).
main(cargo: the test commit @b9e06c3ef)f0c6de6ac(game: @4a279a16f)cargo test -p content a_grown_pack_member_is_raised_and_the_others_are_notcargo test -p content restbl::cargo test -p content1 entries raised for mod files1 entries raised for mod files,2 for the members of 1 packsRisks
132 KB pack. A profile that serves many large packs pays more; that isn't measured.
largest pack is about 24 MiB).
the game's entries. A
.zsmember whose frame records none is taken as four times its bytes, as a loose.zsfileis on
main. The game's own decoders need that size too (host/hos_zstd.c's notes), so the game doesn't loadsuch a frame either.
setting or cache changes. A revert is enough.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (run locally, Testing names them; CI's run waits for approval)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11 Pro, RTX 3090, NVIDIA 610.88: built by longshot-builder play --profile with this PR and the other mod compatibility ports merged, adult Link in Kakariko and Hyrule Field. Two local test mods (the same actor pack, each with a different file inside it grown by 64 KiB, no size table): the start's log raises both files' entries (entry 6456 -> 534848, 5352 -> 2312928; '2 for the members of 1 packs'); main's start keeps the game's. A load that reads the grown files is still to test (Testing).
Possibly related, for context:
mise run test, run locally while CI's run waits for approval (Windows 11, run_all --strict, 12 checks at once), here @
4a279a16fand on main @f577a1aea: 822 passed, 23 failed, 51 skipped here; 820 passed, 25 failed, 51 skipped on main. 19 of the 23 also fail on main (named in Testing); the other four timed out while games built beside the run and pass here alone (--exact). Box ticked.WIP: fix(mods): raise the size table entries of the files inside the packs mods serveto fix(mods): raise the size table entries of the files inside the packs mods serveRecommendation: Request changes. The fix skips valid packs whose zstd frames omit a content size, and can underestimate compressed members with the same kind of frame. Those cases can retain the loading hang this change is intended to fix.
The change compares mod-served packs with the game’s packs and raises resource size entries for grown or new members. It adds work at startup and leaves some valid compressed resources insufficiently sized.
Blocking (2): must change before merging.
game/crates/content/src/restbl.rs:535: A valid pack frame without a recorded content size is skipped entirely. (more on the line) Do: Decode frames with unknown content size using a bounded streaming decoder, then compare their members; add a test using a valid unknown-size frame.game/crates/content/src/restbl.rs:457: Four times the compressed length is not a safe estimate of an unknown-size member’s decompressed length. (more on the line) Do: Determine the actual decompressed size with a bounded streaming decode, including the appropriate dictionary, and test a valid highly compressible frame without a content-size field.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixdoes its part first: Cache member comparisons by the contents of the served and game packs so unchanged packs need not be decoded again at each start.)@fixcan do L1, L2 and L4.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven in the game: the game-free test reports the grown member’s entry increasing, and the Windows startup log reports two raised entries, but neither modified member was loaded during play. The reported size-table step was a median 30 ms after versus 28 ms before with one pack.
Other systems: The fitting code runs at startup on Windows and Linux, independently of GPU. Profiles with many or large packs incur additional decoding and comparison work; their startup cost has not been measured. Hot reload still does not refit pack members.
Switches: None.
Reviewed:
4a279a16f4againstf577a1aeab: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the diff, commit messages, restbl.rs and the changed tests; examined layers.rs, sarc.rs, the host zstd decoder and the applicable standards. Skimmed the changed documentation. docs/review-checklist.md is absent. No recorded runs or generated files were changed.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run during review. The author reports 269 content tests passing and a Windows game startup; CI is still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as snaildev99 took it out of WIP. Nothing was run; a maintainer decides.
@ -406,0 +454,4 @@if len == 0 || at + len > p.len() {return n.saturating_mul(4);}let mut v = 0u64;L2 (blocking): Four times the compressed length is not a safe estimate of an unknown-size member’s decompressed length.
When: A mod can grow a .zs member to a highly compressible payload while its frame omits the content size. Its compressed length can remain near or below the original member’s compressed length, so the comparison skips the grown resource or raises it far too little and its load can hang.
Do: Determine the actual decompressed size with a bounded streaming decode, including the appropriate dictionary, and test a valid highly compressible frame without a content-size field.
@ -406,0 +532,4 @@) -> Result<usize, Unread> {let rel = entry.rel();let Some(mod_arc) = host.host_zs(served) else { return Err(Unread::Served) };let orig = if let Some((spelled, _)) = host.game_file(rel) {L1 (blocking): A valid pack frame without a recorded content size is skipped entirely.
When: When a mod compresses an actor pack without a content-size field and grows a member, host_zs returns None, so raise_pack leaves the member’s stock entry unchanged. Loading that member can still hang even though the game can consume the pack.
Do: Decode frames with unknown content size using a bounded streaming decoder, then compare their members; add a test using a valid unknown-size frame.
4a279a16f4f0c6de6ac5Rebased onto main @
3a0f7d8f7for the base conflict; here @f0c6de6ac. Tested (the game again on this head),mise run test(against main @3a0f7d8f7: every failure also fails on main) and Measurements are updated. Answers to the review below.L1 (a pack frame with no content size is skipped): not changed. The game doesn't load a
.zsfile whose framerecords no content size, so a pack like that has no member load to size. The game streams its
.zsfiles through itsown zstd wrapper, and that wrapper fails such a frame at the start:
host/hos_zstd.cdoes what the game's wrapper doesthere (its notes, and the check at line 354). The frames the builder writes carry the size because the game sizes its
buffer by it (
builder/crates/build-assets/src/zs.rs,with_content_size). The pack fails to load as a file. The fitnames it in the log as unreadable (the mod's copy), which tells the mod's author what is wrong. A bounded streaming
decode would also mean changing
host/zs.c'sdecode, which every zstd read of the host goes through: the archivemerge, the mods' size tables, the prompts and the sounds. That is a change of its own. If a run in the game shows a
pack like that loading, this comes back.
L2 (four times the bytes for a
.zsmember with no content size): not changed, for the same reason. The game'sdecoders need the frame's content size. The stream decode fails a frame without one, and the whole-buffer decode's
callers give exactly the content's size (
host/hos_zstd.c's notes). So a member like that doesn't decode in the game,whatever its entry. Four times the bytes is also
main's rule for a loose.zsfile:fit()takes every served.zsfile's size fromhost/zs.c'shos_zs_content_size, which does the same. Members follow that rule so the twoagree. Reading the real size needs the same change to
host/zs.cas L1.L3 (a load of the grown member in the game): still to test, by hand. Adult Link through a load with the mod and no
size table. It stays under Still to test until it has run.
L4 (startup cost with many packs): the measurement is still to run. The cache isn't made.
main's fit keeps norecord between starts either, so the whole table is made again at each start. A cache for the members alone would mean
a new record in
modcache/, keyed by each served pack's content hash and the game copy's version and path, holding themember sizes, with tests for a miss, a hit and a damaged record. Each start would still read and hash every served
pack, so it would save only part of the 2 ms a 132 KB pack costs now (the two decodes and the archive walks). If the
measurement shows the cost matters, the fix is a cache of the whole fit by its inputs, in a pull request of its own.
Still to test now lists the measurement the review asked for, which the answers above say is still to run.
@review
Recommendation: Approve. The code is ready: only testing is left. The tests show that grown pack members receive larger entries, but the reported game run did not load a modified member. Startup cost with many served packs also remains unmeasured. Recommend approval; not approved on the forge.
The change raises resource size table entries for grown or new members of packs served by mods, reducing the risk of a loading hang. It adds pack decoding and comparisons at startup.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixdoes its part first: Cache member comparisons by the contents of the served and game packs so unchanged packs need not be decoded again at each start.)@fixcan do L4.Since the last review (on
4a279a16f4)Withdrawn (it was wrong): L1 (A valid pack frame without a recorded content size is skipped entirely.); L2 (Four times the compressed length is not a safe estimate of an unknown-size member’s decomp…)
Still open: L3 (The reported game run did not reach a load of a modified member.); L4 (Startup cost for a profile serving many packs is unknown.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven in the game: the regression test reports the grown member rising from 5352 to 10720 and passing here after failing on main. The in-game log shows two entries raised, but neither modified member was loaded.
Other systems: The size fitting runs on Windows and Linux and includes merged packs. The reported game run is on Windows; the cost for profiles with many packs is unknown.
Switches: None.
Reviewed:
f0c6de6ac5against3a0f7d8f7f: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the changed Rust files and tests, the documentation diff, and the relevant zstd decoder code and notes. The combined tool output truncated portions of the full-file reads; no review checklist or pull request template was found in the file search.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The author reports 269 content tests passing and an in-game startup check; CI is still running.
Overlaps and merge order: None found in the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.