After the last regular shader, dmsh_build.py wrote no more progress to DMSH_PROGRESS, leaving ShaderWatch frozen at a stale ~99% count through mesh-library compilation, library-image publishing, and the c1_guard.py and cb_extent.py table passes. ShaderWatch also mapped every step other than cache check back to compiling, hiding compiling RT library. Have dmsh_build.py report all of its phases directly through DMSH_PROGRESS: flush the final counts of cache check and compiling, flush immediately on step changes, report compiling mesh libraries across _mesh, pass an optional on_progress callback through publish_library to shader_lib.write for writing the library image (or writing the Mac / iOS library image on dual-image builds, with file counts and bytes written), and report c1 guard and uniform read extents before unlinking DMSH_PROGRESS at exit. Simplify ShaderWatch to forward step, counts, unit, and formatted byte notes straight from DMSH_PROGRESS. Regenerate dm/gfx/nvn/dmsh_chain.h. Checked: 159 tests across test_nsp_mac, test_shader_lib, test_shader_toolchain_cache, test_nsp_chain, test_dmsh_abi, test_dmsh_code_fp, test_pr_areas, test_usage, and test_docs; ruff check (0 new findings). Co-authored-by: UserDerezzed <[email protected]>
193 KiB
Packing
Game packages
An iOS build stops when the profile has no prewarm seed list
- Symptom: after the shader build,
build_ipa.shstops atcopy shader tablesbecausepso_manifest.tsvdoes not exist. This also stops the shell's game-framework build. - Cause: a profile may have no recorded pipeline prewarm seeds yet. The host supports that state and still reads the device's own list, but the iOS packager required the optional seed file alongside the required shader tables.
- Fix: copy a recorded seed list when present and report its absence otherwise. Required shader tables and a failed copy of an existing seed list still stop the build. No seed records are invented, and shader cache inputs are unchanged. This does not change shader rebuild or resume decisions.
- Found on: Pokémon Pokopia, NX2Apple issue #922. The separate report of repeated shader compilation remains open.
PFS0 files extend beyond a truncated package
- Symptom:
nx_extract --aocaborts with an unhandledResultFsOutOfRange (2002-3005)when a package's file table declares bytes that are not present. - Cause: the PFS0 header and name table were checked, but each payload-relative file offset and size was trusted. LibHac later tried to read the missing bytes, before the extractor could issue its normal damaged-package diagnostic.
- Fix:
PackageStoragevalidates every file range against the original payload before mounting or adding a virtual final name terminator. The size check uses subtraction to avoid 64-bit overflow, and accepts an empty file at EOF.OpenNspprobes the XCI header only when enough bytes exist, then routes malformed PFS0 headers and payload ranges to a named[RED] the NSP is damagedmessage and exit code 3.--allow-damagedcannot supply missing container bytes, so it does not bypass this check. The source is never changed. - Found on: Diablo II: Resurrected, whose separate licence-only DLC package was truncated (issue #2013). Main now has the shared CASC/SHAD reader; that separate shader-discovery fix does not repair missing package bytes. The reported base game alone (v0) remains unchecked, as the game note records.
- Check:
dm/tools/tests/test_pfs0_storage.pyexercises synthetic payload truncation, out-of-range and overflowing spans, an empty file at EOF, and the CLI's damaged-input exit with and without--allow-damaged, with both normal and missing-final-NUL name tables.
PFS0 file-name table missing its final NUL
- Symptom: package identification stops with
ValueError: subsection not foundinpfs0_names, or LibHac reportsResultFsPathNotFoundopening the last file of an NSP. - Cause: older NSZ writers omitted the final NUL in the PFS0 string table. The final name is bounded by the table length, but the Python scanner required a terminator and LibHac reads names as NUL-terminated strings.
- Fix:
nx_extractsupplies LibHac with a virtual header containing the missing NUL followed by the original payload storage. File offsets remain relative to that payload, and the source package and encrypted NCA bytes are unchanged. Truncated tables and out-of-table name offsets still fail. Synthetic package tests cover the reader and payload preservation (test_pfs0_storage.py). The Python scanner's own table reader (pfs0_names), which accepted the table boundary as the end of the final name, is gone: the scan reads every package throughnx_extract(An update is taken for the version in its file name). - Found on: Moving Out 2 (
010065D018172000), base 1.1.254 NSP and update 1.3.315 NSZ. Package reading was checked, not gameplay.
A NUP with complete standalone updates stops at "no base game"
- Symptom:
no base game, only update packages: pack the base game and its update into one NUP, even when the update carries the complete game's files (issue #1195). - Cause:
pack_nup.scanrequired abaserecord. NUP v1 permits a container without one when every update has thestandalone_updateflag (package flags bit 0, SPEC §3.1.2). The reference packer writes one for a dump with nobase/folder and, since its commit92089de3, for an emptybase/too; before that an emptybase/gave an empty base record, which got through the check. The issue was filed before that commit, so its NUP came from a dump with nobase/folder or from another packer; the file itself was not seen. - Fix: no base record and a base record with no files are one case:
scangivesNonefor the base, and only the update versions present are offered. Both packing entry points select the newest update by default; requesting version 0 fails. The selected update must haveexefs/main,exefs/main.npdmand its own RomFS; it cannot borrow another update's RomFS. Control data the update lacks comes from the record that holds application metadata: the empty base record, else the first package (SPEC §5.1). A base with files still supplies the RomFS for an update without one. Program-ID, DLC, content-size and SHA-256 checks apply as before. A version that cannot be packed stops at a[RED]line: the disk check reads its RomFS folder before extraction, socli()catchespack_nup.Error. - Not known from the file: whether the update is the whole game. The flag does not promise it (the spec says such an update needs a matching base elsewhere), and an update holding only changed files would pack and then fail at boot, after a full shader build. The scripts print that the update is taken as the whole game. Measured: both NUPs at hand have an update RomFS that holds every path of its base (Age of Imprisonment: 2,065 base files, 2,153 in the update, none missing; Yoshi and the Mysterious Book: 147 and 147, none missing).
- Found on: Mario Kart World. Reproduced with its base dump repackaged by the reference tool as a standalone-update fixture; this checks packaging, not the reported 1.8.0's contents or gameplay. Synthetic tests cover both entry points, both forms of no base, multiple versions, control data, DLC and incomplete updates.
A registered update with its own shader tables is reported red or packed with another version's shaders
- Symptom: packing a registered build from a derived profile on a multi-build game prints
[RED] this Mac app uses <ver> (<disp>), which game profile <id> was not brought up on (...): its settings, with this version's own shaders; every module is a registered build, naming<ver>among the registered builds. Or, when a profile registers an update whose shaders are not inshader_versionsand both the base and update are present, the build stays non-derived and packsshader_versions' shader libraries into the update instead of the update's own shaders. - Cause: two separate assumptions in
scripts/build_ipa_from_nsp.py. First,report_profile_statuscomparedg.builds() == reg.builds()(the whole build table, including other versions and thedisplaystring), whereasderive_profilekeeps only the packed version's row, so a multi-build profile never matched. Second,mainassumedshader_versionscovers every registeredbuildrow wheneverall(v in have for v in need)held, even whenpkg_verwas not inshader_versions. - Fix:
profile_derivation_reasontreats committed shader tables as coveringshader_versionsplus any additional registered builds explicitly verified inshader_covers(Hades IIv655360, FIFA 23v196608); any other registered build derives its own shader tables even whenshader_versionsis present (and avoids extractingshader_versionsunnecessarily).report_profile_statuscomparespkg_ver's module build IDs (ignoringdisplay) againstreg.builds().get(pkg_ver)and reports registered builds without[RED], while mismatched, mixed, or unregistered modules stay red.dm/tools/tests/test_nsp_registered_update.pycovers all cases. - Found on: Mario Kart World 1.8.0 (
v917504, 11,601 shaders vsv0's 11,558; PR #2621) and existing multi-build profiles such as Super Mario Bros. Wonder when packed without allshader_versions.
A NUP or a dump of a game with no profile stops before the survey
- Symptom:
[RED] a NUP packs only a game with a profile, and <title ID> has none: the survey that makes a provisional profile reads NSPs, or the same line for a dump folder (issue #1265). A folder holdingexefs/andromfs/directly, or onlyupdates/<version>/, was not taken for a dump at all: the script asks forprod.keys, then stops withno NSP with a readable title ID. - Cause: the survey and the build ID lookup (
same_build) rannx_extract --manifest, which reads NSPs.pack_dump.is_dumpasked forbase/exefs/main.npdm. - Fix: each source leaves the same files for the survey:
survey_nupreads the newest version from the container (its ExeFS, a RomFS manifest innx_extract's format: path, size, first 32 bytes,Nup.headinflating only those; the NROs whole and the control data), andsurvey_dumpfrom the folder, whose name names the game, as a dump has no control data.same_buildreads main from the container or the folder. A dump may have nobase/when an update's folder holds code and a RomFS, andexefs/andromfs/directly in the folder, asnup extractwrites them, count asbase/: version 0, so a profile that registers another version packs them from a derived profile. - Found on: Star Fox (
0400E88025B1A000, update v131072; no profile in the repository then), The Legend of Zelda: Ocarina of Time (0400486024DEC000, issue #1265) and Fire Emblem Fortune's Weave, whose dump holdsupdates/131072/alone.
A damaged file in a NUP or a dump has no hash to fail
- Symptom: the game reloads one asset for ever: a background loader takes about a core and the process several (Ocarina of Time: 412% CPU on the Mac,
OptimizeChangeBancandParallelDecompThreadbusy all session, one model and its texture opened about 22 times a second). Or, from the NSP script:vN: K file(s) whose bytes do not start as their names promise (a .zs file that is not a zstd stream), so the game files are damaged, then the files. - Cause: the game files themselves. An NSP's files are checked against the NCA's hashes at extraction, so a damaged one stops the build (
--allow-damaged). A NUP or a dump folder carries no such hashes: whatever bytes it holds are packed. On one NUP of Ocarina of Time three.zstextures began with 12,288 zero bytes, so no zstd frame: the game could not decompress them, and its loader asked for them again on every pass (PR #1530). The container's own SHA-256 of each file matched, so the bytes were like this when the NUP was packed. Another NUP of the same version holds all three as zstd streams, and none of its 102,185.zsfiles fails the check. - Fix: the NSP script reads the first bytes of every file whose name promises a format (
romfs_image.FORMAT_HEADS:.zsstarts with a zstd frame or a skippable frame) once per extracted image (check_formats, after extraction; the result is kept inRomFS.img.formatsbeside the image until the image changes: Ocarina of Time 16 s from a USB SSD) and stops naming the damaged files: pack again from a good copy of the game.--allow-damagedlists them and packs them as they are. The host serves a game's files as they are: substituting other files for damaged ones would hide the damage and change what the game draws. - Found on: The Legend of Zelda: Ocarina of Time, a contributor's NUP of v131072.
A NUP whose folder contains itself
- Symptom:
pack_nup.py, or the NSP script on a NUP, ends in a Python traceback (RecursionErrorintree_bytes) instead of a[RED]line. - Cause:
Nupchecked each folder's child range and each child index against the table sizes, but not that the folders form a tree. A table of contents whose hash matches can still name a folder, or one of its ancestors, as its own child;scansums the base package's size by recursion and never ends, andentries(the RomFS image's walk) would loop. - Fix:
Nupwalks the folder graph once, depth first without recursion, and refuses a folder that contains itself, naming it (contains itself (damaged file)), before any other walk sees the container. - Check:
test_nsp_nupRead.test_folder_cycle_refused: a folder made its own parent, then a cycle of two folders, each with the TOC hash fixed up, are refused, and the script exits 1 with no traceback. Without the check the container opens. - Found on: a code audit; no damaged NUP of this kind is known.
A NUP icon is written as control data
- Symptom: the JPEG icon in a NUP is written as
control.nacpand the display version is written asicon.jpg. A wrong-size NACP can also supply incorrect application and DLC IDs during scanning. - Cause: nup PR #20 replaced explicit TLV values with an enum that starts at 0. SPEC §5 starts at 1, so each type in a block produced by that writer is one too low. The upstream writer fix in nup PR #22 starts the enum at 1. In nxnative, scanning used the offsets of the ID fields as its only NACP size check.
- Fix:
Package.meta()normalizes a shifted block at read time. NACP and icon payloads determine the numbering when they can, with type 0 or a non-32-byte type 7 as fallback markers (nup PR #32). The same reader omits NACP records whose size differs from0x4000before scanning or extraction uses them. Extraction reports these decisions once per package. - Found on: a sample written with upstream
nupata4840f06reproduced the swapped files. A Resident Evil 4 archive confirmed shifted numbering. A Super Mario Bros. Wonder archive contained a valid NACP at type 2 alongside shifted records.
A Switch 2 Edition NUP stops at "2 base packages" or "is not a base title ID"
- Symptom:
[RED] <file>.nup: 2 base packages,base program ID 040015100B514001 is not a base title ID, or010015100B515001 is not a DLC of 040015100B514001, from a NUP of a Switch 1 game's Nintendo Switch 2 Edition (PR #2692). Packed by hand on its own RomFS, the Switch 2 program crashed within a second ofnnMainon a nullthisin a constructor: with no heap sizes the engine's heaps were never made. With an add-on older than the program:[RED] game asks to show an error: its upgrade add-on content is older than this program needs, thenCRASH sig=4at the game's own trap (before the hook, a crash insdkundernn::applet::StartLibraryAppletImmediately). - Cause: a Switch 2 Edition is one application of two programs, and
scantook one base package and derived the application and its DLC from that program's ID. The Switch 1 program (010015100B514000, index 0) holds the game data; the Switch 2 program (040015100B514001, index 1) has a RomFS of a few files of its own, and its ID differs from the application's above the low 12 bits. The game data is not laid over the Switch 2 program by the system: Super Mario Bros. Wonder's Switch 2 code mounts its own RomFS ascontent:, and when that has noSystem/AddressTableit mounts program 0's RomFS withnn::fs::MountRom(name, 0, …)asconorig:and the upgrade add-on withnn::fs::MountAddOnContentasaocup:, and looks up each file inaocup:, thenconorig:. Before that it readsaocup:/System/AocUpgradeVersion.txtand stops below 3 (main+0x132b9b4, 1.2.1) withnn::err::ShowUnacceptableAddOnContentForUpgradeVersionError, which the host did not answer. The host ignored that program index and served the program its own RomFS (fs::MountRomwith a program index). NUPs come in other layouts too: on S790, Wonder's and Xenoblade Chronicles X's Switch 2 Editions each hold one base package, the Switch 2 program's, whose packer had already merged the game data into its RomFS. - Fix:
scangroups base and update packages by their NPDM's program ID; the low 12 bits are the program index, and the programs must belong to one application, which the NACP names (SaveDataOwnerId, else the program ID above those bits). It packs one program (--program N, default the highest index, the Switch 2 program), with its own updates. Each other program's RomFS, at that program's newest update no higher than the packed version, goes beside its own asromfs_programs/<index>.img. The host'sMountRom(name, index, …)mounts that image (DM_ROMFS_PROGRAMS, defaultromfs_programsbesideDM_ROMFS), and its own RomFS when there is none. The Mac app (aGameDataProgramsdata bundle), the IPA and the Xcode project carry the folder beside the RomFS, and the iOS app names it when its RomFS is in Documents. A DLC's index is its title ID minus the NACP'sAddOnContentBaseId(else the application's ID + 0x1000). The add-on is packed as DLC only, laid over no RomFS: the game checks its version and layers it itself, where a merge into the program's RomFS skipped both. The survey lists the other programs' files after the program's own, and the format check reads their images. The host answers the upgrade-version error applet with the red line above. - Check:
test_nsp_nupPrograms (the default and--program, both programs with updates, the one-program layout, the refusals, the script's survey, disk estimate and format check),test_nsp_mac_apptest_other_programs_romfs_beside_the_romfs,test_xcode_workflow(staging),t_fs(an index with an image, one without,DM_ROMFS_PROGRAMS). On the Mac (M-series, 1.2.1, provisional profile): the S790 NUP packed as it is (one base, merged RomFS, which hasSystem/AddressTable, so the game mounts no other RomFS) reaches the title, the menus and the character choice. Laid out as PR #2692's NUP, the program's own 144-byte RomFS (System/RegionLangMask.txt) with a program 0 image beside it: the game mountsconorig:fromromfs_programs/0.imgandaocup:fromaoc/1.img. With the Switch 1 1.2.1 RomFS and the S790 add-on (AocUpgradeVersion.txt1) it stops at the version check, as the console would; with that file made 3 it reads its Switch 2 heap sizes fromaocup:and needs one file neither holds (RSDB/DVModelBakeInfo.Product.110.rstbl.byml.zs, only in the S790 NUP's merged tree), and with that tree as program 0's image it reaches the opening in the Flower Kingdom. A consistent two-program NUP of 1.2.1 was not at hand. - Found on: Super Mario Bros. Wonder – Nintendo Switch 2 Edition + Meetup in Bellabel Park (
040015100B514001, 1.2.1), first packed by a contributor in PR #2692, whose RomFS merge this replaces; Super Mario Bros. Wonder is its Switch 1 program.
A provisional profile of a Switch 2 game shows no SDK and a Switch 1 memory pool
- Symptom: the survey of a Switch 2 game says
SDK: ?andno SDK version string found, and its provisional profile hasapp_pool 0xCD500000. - Cause: the SDK version pattern did not take the variant the Switch 2's SDKs name (
NintendoSdk_nnSdk-Generic_21_4_4), andguesshad one pool, a 4 GB Switch's. - Fix: the pattern takes the variant, and an
sdkbuilt for the Switch 2 (spec: Ounce, asdm_sdk_ouncereads it) gets the 9 GB pool every Switch 2 profile has. Open: only the pool changes; a game with system resource keeps the 5 GB block (Star Fox's profile has 21 GB with a 16 GB alias region), so a provisional profile may still not fit and needs the bring-up. - Found on: Star Fox and Kirby Air Riders (
040077201BE50000; no profile), read from their NUP and extraction; first reported with Fire Emblem Fortune's Weave.
Build tools
Stopping a build left its tools running
- Symptom: after the NSP script was stopped in Spyder (its interrupt), or by a front end's SIGTERM, the tool it was running went on: a shader build or
build_ipa.sh'sxcodebuildkept the CPU busy and wrote into the build folder that the next build reads, and the script could wait for it with no end. A regression run (regress.py) stopped during a shader build whose direct child ignored SIGTERM for 10 s left the build's workers running. A tool's child still writing after the tool's own exit was taken for a finished step. - Cause:
run(the NSP script) started each tool in the script's own process group and on an interrupt stopped only that tool (terminate, then a wait without a limit); a terminal's Ctrl-C reaches the whole foreground group, but Spyder's interrupt reaches only its kernel, and nothing handled SIGTERM, so the tool's descendants were never told.run_heavy(regress.py) did start a group of its own, but its fallback after 10 s killed only the direct child, without reaping it, and a child left running after the job's own exit went unnoticed.runalso read the tool's output until its end, so a descendant holding the output kept it waiting after the tool had exited. - Fix: both run their tool through
dm/tools/proc_group.py: the tool leads a session and process group of its own, and on an interrupt, a SIGTERM or an error (a log that cannot be written) the whole group gets the signal that stopped the caller (SIGINT for an interrupt, SIGTERM otherwise), resumed first when a pause (run_heavy's measuring lock) left it stopped; what is left after 5 s is killed and the tool reaped. A process of the group still running 5 s after the tool's normal exit, holding its output or not, is stopped and fails the step as an exit code would (what it writes may be incomplete); the message names it. The tool's exit is seen while its output is read, so a holder of the output no longer stalls the step. The NSP script'scliturns SIGTERM into an exit with code 143 (the front end's contract), with the handler set only while it runs (Spyder's kernel gets its own back). A process that leaves the group itself (setsid) is out of reach of group supervision: it is neither signalled nor waited for (one still holdingrun's output fails the step, unnamed).patch_nso.py's pool of forked workers is outside this change: they stay in the rewrite's group, and the rewrite's SIGTERM handler (sys.exit(143)) ends the pool, which stops and reaps them.boot_mac, the rewrite pool, regress.py's game runs andbench.pystill stop their direct child only: moving them toproc_groupis a separate change.dm/tools/tests/test_proc_group.pyruns real process trees (fixtures/proc_tree.py) throughrun,run_heavyandcli. - Found on: no game; found in a review of the build scripts, with a repro (an interrupt raised in
run's progress callback, after which the tool's child kept writing).
Closing the terminal left a build's tools running
- Symptom: after the terminal running the NSP script or
regress.pywas closed, the tool the script was running (a shader build,xcodebuild, a game under the harness) went on running with no parent, writing into the build folder; the script itself had gone without its cleanup. - Cause: since Stopping a build left its tools running, each tool leads a session and process group of its own, so the shell's SIGHUP on a closing terminal, sent to its job, reaches the script alone. Neither script handled SIGHUP, and its default action ended the script before the tool's group was stopped; before that change the tool was in the script's group and got the SIGHUP too. Reproduced with a script running
sleep 30throughproc_group.Group: a SIGHUP to the script's group ended the script and left the sleep running, where a plain child in the script's group went with it. - Fix: the NSP script's
cliturns SIGHUP intoStoppedas it does SIGTERM (the running tool's group stopped, the stage line ended, exit code 129; both handlers set only whilecliruns and given back after), andregress.py's main exits with 129 on SIGHUP as with 143 on SIGTERM, so the finally blocks stop the game or build's group.test_proc_group(Cli.test_sighup_during_a_tool) sends a real SIGHUP to the script while a tool's group runs and checks the group is gone and the tool got its SIGTERM. - Found on: no game; found in the audit of the review's process-group change.
Stopping a build while it replaced an output left that output half deleted
- Symptom: none seen on a game. An interrupt, a SIGTERM or a failed delete while the NSP script replaced one of its outputs (an extraction, the rewritten modules, the NROs, a DLC folder, a shader capture, the shader package) could leave that output half deleted at its real path, and a reuse check that looks for a few files (
extract's:ExeFS/main,RomFS.img, the RomFS marker) could take it for a finished output on the next run. - Cause:
swap_indeleted the old output in place (rmtree(dst)) and only then renamed the staged one (<dst>.partial) in; its comment said the old one was untouched on failure. Its callers already write their completion stamps only after the swap, so the old output was stale whenever it was replaced: the loss was the half-deleted folder, not the old contents. - Fix:
swap_inrenames the old output aside (<dst>.old.partial, a name the build ignores as it does every.partialfolder), renames the new one in, and only then deletes the old one; a failure or an interrupt before the new one is in renames the old one back. The output is always the whole old one, the whole new one, or absent. This is recoverable, not atomic: a SIGKILL between the two renames leaves no output (the old one aside), which the next run rebuilds, and a delete stopped after the new one is in leaves the aside folder's remains until that output is replaced again (disk space only). A failed delete of the old output still fails the step, after the new one is in.dm/tools/tests/test_nsp_swap_in.pyruns each case in a process of its own (fixtures/swap_in_run.py): failed and interrupted renames, interrupted and failed deletes, an earlier run's aside folder, a SIGKILL between the renames, each followed by a rerun. - Found on: no game; found in a review of the build scripts. The half-deleted output was reproduced with the old
swap_in(an interrupt during its delete); thatextractwould have reused one is inferred, not reproduced. - Since: the step 15 audit found three gaps, each reproduced against the script before it: a rerun after a SIGKILL between the two renames deleted the aside copy, the old output, before publishing again, so a rerun that then failed left no output; an interrupt between the rename aside and the second rename (outside the
try) put nothing back; and a failure to rename the old one back raised that rename's ownOSError, hiding the first failure and where the old output was. Now the rollback is judged by what is on the disk (the old output aside and nothing in place: it goes back), a failed putting back raisesBuildErrornaming<dst>.old.partial, and an aside folder a run finds is put back when nothing is in place and deleted only when the new output went in. The NSZ decompression publishes throughswap_intoo instead of deleting its stale output first.test_nsp_swap_in: a kill between the renames then a rerun that fails (the old output back in place), an interrupt right after the rename aside, and a putting back that fails (BuildError, nothing deleted, the next run publishes); all three fail on the script before.
Building needed .NET, and finding its runtime kept failing
- Symptom: before running the NSP script, a player had to install the .NET SDK 10, and builds then failed in ways that were about .NET, not the game: a translator that finds no runtime of its architecture (GitHub issue #54, #248), a Homebrew runtime the apphosts cannot find, a dll tied to one architecture (#803), the entries below. GitHub issue #1853 asked for the tools to be rewritten in Python or Objective-C.
- Cause: both C# tools were framework-dependent: the shader translator a committed apphost with its dlls, which needs a .NET 10 runtime of the architecture it starts as, and
nx_extractbuilt withdotnet buildon the player's Mac at each run. Neither needs .NET itself: Ryujinx's shader library and LibHac compile ahead of time. A rewrite would have replaced about 49,000 lines of Ryujinx's translator and LibHac's NCA, patch and container layers with new code, changing every game's shaders or extraction on any difference. - Fix: both are committed as native universal executables (NativeAOT, arm64 and x86_64),
dm/gfx/tools/dmsh_xlate_bin/dmsh_xlateanddm/tools/nx_extract_bin/nx_extract, whichdm/tools/native_tools.shbuilds (the .NET SDK is needed only there). Each embeds its sources and prints their digest with--source-sha:tool_lock.pyrefuses a translator, and the NSP script (find_nx_extract) annx_extract, not built from the sources in the repository, and the lock records the translator's own fingerprint in place of its dlls'. The NSP script no longer asks fordotnet, setsDOTNET_ROOTor buildsnx_extract.dm/tools/tests/test_native_tools.pychecks that both are universal, alone in their folders, built from their sources and, for the translator, the lock's. Measured before landing: the native translator wrote the same SPIR-V, reflection files and messages as the framework-dependent one for 2,058 shaders of Octopath Traveler II (Maxwell) and 672 of Splatoon Raiders (Ampere), byte for byte, and the nativenx_extractthe same ExeFS and merged RomFS image (651 MB) of Big Brain Academy: Brain vs. Brain with its update, and the same--contentsand--keysoutput. The cost: each translator rebuild adds about 1.4 MB to the repository's history (the dlls about 0.3 MB), since the executable holds the runtime; the build is not byte-reproducible, so a rebuild only follows a source change. - Found on: every game's build; reported in GitHub issue #1853.
The committed translator crashes at address 0 on macOS 26
- Symptom: on macOS 26 the NSP script stops before extracting anything with
[RED] the shader translator does not run (exit code -11), anddmsh_xlate --source-shaexits 139:EXC_BAD_ACCESSat address 0 with pc 0, called fromdmsh_xlate +0x5adc. On macOS 27, and underarch -x86_64, it runs. - Cause: the arm64 slice committed with the native tools imported
pipe2weakly: its minimum macOS is 12.0, andpipe2is declared from the macOS 27 SDK on. The .NET runtime'sSystemNative_Pipe, which opens the signal pipe at start, was compiled to call it without a check, so on a Mac without it the import binds to 0 and the call jumps there. Microsoft's NativeAOT runtime pack (10.0.14, built against the macOS 15.5 SDK) has no such call: a build with it on the same sources has nopipe2import. So that slice was linked with anotherlibSystem.Native.a, one configured against the 27.2 SDK; which .NET gave it is open (a source-built one, such as Homebrew's formula, builds its host architecture's pack against the installed SDK, which would also explain the clean x86_64 slice). - Fix: the translator is rebuilt with Microsoft's .NET SDK.
native_tools.shrefuses a slice with a weak import before it joins the slices, andtest_native_tools.py(test_no_weak_imports) reads the symbol tables of both committed tools, so a function newer than the minimum macOS cannot be committed again from any Mac.nx_extracthad none. Measured: over the translator jobs of a full Cuphead shader build, the new arm64 slice wrote the same files as the old one, byte for byte. Not run on macOS 26 here. - Found on: every game's build on macOS 26 (GitHub issue #2190, #2239, #2227).
Homebrew .NET is on PATH but apphosts cannot find the runtime
- Symptom: the first extraction stops with
nx_extract exit code 131and.NET location: Not found, even thoughdotnetis onPATH. The shader translator can fail the same way. - Cause: standalone .NET apphosts search runtime roots and registered installations, not
PATH(.NET runtime discovery). Homebrew's formula installs the runtime underlibexecand itsbin/dotnetcan be a wrapper that setsDOTNET_ROOTonly for its own child (Homebrew caveat). Resolving that wrapper's symlink givesbin, not the runtime root. - Fix: resolved for good by native tools, which need no runtime;
configure_dotnetis gone. Before that,scripts/build_ipa_from_nsp.pyconfigure_dotnetderived the root from theMicrosoft.NETCore.Appentry indotnet --list-runtimes, using the build's environment, before any extraction or survey. It exportsDOTNET_ROOTboth to that environment and toos.environ, for tools launched with an explicit environment and those that inherit it. Caller-supplied roots, including architecture-specific overrides, retain precedence. A failed or malformed probe leaves the environment unchanged rather than guessing the wrapper's directory. - Found on: Balatro, first extraction with Homebrew .NET (PR #284). Applies to every game's build on that installation setup.
The shader step stops with an empty xlate_source
- Symptom: the extraction and captures succeed, then the shader step stops with
translation chain tools do not match the lock file: xlate_source: lock … / actualand nothing afteractual, which reads like a stale translator. - Cause: the translator (
dmsh_xlate_bin/dmsh_xlate) is a universal framework-dependent apphost. When it finds no .NET 10 runtime for the slice it starts as, it exits 131 with an empty stdout. A Python under Rosetta (an Intel Homebrew's) starts it as x86_64, and it finds only the arm64 .NET; extraction is not affected, becausenx_extractis built for the SDK's own architecture only. An Intel .NET on Apple silicon, or aDOTNET_ROOTthat names one, fails the same way.tools_now(then indmsh_chain.py) kept only the stdout ofdmsh_xlate --source-sha, without its exit code or stderr, so the apphost's own message was lost. - Fix: the translator is now native and needs no runtime (native tools); the checks below stay, for a translator that does not start. The NSP script checks the environment before extracting anything:
check_native_pythonstops under Rosetta (sysctl.proc_translated), andcheck_prereqsstarts the translator once with--source-shaand stops with its first message line (check_translator). It also checks glslang and, for an iPhone build, the iOS SDK (check_ios_sdk, before the Metal check, whose message would blame the Metal toolchain).own_compilers.pyno longer asks a Mac-only shader build (DMSH_TARGETS=mac) for the iOS Metal compiler.tool_lock.pyrecords--source-sha's failure instead of its empty stdout (xlate_embedded:does not run (<first message line>)), sodmsh_build.pyrun directly and--update-lockstop with the same message as the NSP script, without the lock and rebuild lines. The tool checks used to be indmsh_chain.py, which is part of the chain version and of every shader's cache key, so that fix rebuilt every library; they now live intool_lock.py, outside both, and a change to them rebuilds nothing. - Found on: NX2Apple builds (LNPANDY/NX2Apple#31, item 3; PR #477, PR #487); reproduced with
arch -x86_64. Applies to every game.
An Intel Mac cannot load the bundled translator's dll
- Symptom: on an Intel Mac, the NSP script stops at its translator check with
[RED] the shader translator does not run (Unhandled exception. System.IO.FileLoadException: Could not load file or assembly '…/dmsh_xlate.dll'. The assembly architecture is not compatible with the current process architecture.), although the .NET 10 runtime for x86_64 is installed. - Cause: the launcher
dmsh_xlateis universal, butdmsh_xlate.dllbeside it was arm64-only (PE32+, machine0xAA64). A .NET build for a runtime ID (-r osx-arm64) sets an executable'sPlatformTargetto that architecture unless the project names one, and the repository had no single command for rebuilding the translator, so the bundled dll flipped between AnyCPU and arm64 from one rebuild to the next. The Ryujinx libraries stayed AnyCPU, because a library does not take its architecture from the runtime ID. - Fix: resolved for good by native tools: the translator has no dll, and
test_native_tools.pychecks its two architectures. Before that,dmsh_xlate.csprojpinned<PlatformTarget>AnyCPU</PlatformTarget>, so a build with any-r, or none, gives an AnyCPU dll (PE32, machine0x14C, IL only).dm/tools/tests/test_xlate_anycpu.pyreads the PE/CLI headers of every dll indmsh_xlate_binand the launcher's Mach-O header, and fails when a dll is tied to an architecture or the launcher lacks x86_64 or arm64; it needs no .NET. The rebuilt translator writes the same SPIR-V and reflection files as the arm64-only one (9,556 shaders compared byte for byte). - Found on: an Intel MacBook Pro building any game (GitHub issue #803, which bisected the flips). Applies to every game.
The Vulkan shader step fails with Argument list too long: 'xcrun'
- Symptom:
vk_shaders.pystops withOSError: [Errno 7] Argument list too long: 'xcrun'after the Metal compiles, in themetalliblink. - Cause:
metallib()passed every.airfile as an absolute path in one command. The NSP script runs it withTMPDIRset to the work folder, so each path holds that folder's name; a game with thousands of generated modules (Super Mario Galaxy: 3,083 captured shaders, more with the dual-source variants) under a long NSP folder name exceeds macOS's 1 MBARG_MAX. - Fix:
metallib()runs from the files' common folder with relative paths and an absolute output path, so the command length no longer depends on the work folder's name. - Found on: Super Mario Galaxy, with its dump in a folder named after both games of the cartridge. Applies to every Vulkan game's shader step.
The shader step stands at 99% after the last shader
- Symptom: a shader build's progress line stops just short of its total (
42,811 of 42,848for Ocarina of Time, every shader from the cache) and stays frozen through the late mesh, library-image and table steps before the stage ends, which looks like a hang. - Cause:
dmsh_build.pywroteDMSH_PROGRESSat most every half second duringcache checkandcompilingwithout flushing the final count, emitted no progress for mesh libraries,publish_library(40–49 s for Ocarina of Time's 10.7 GB Mac image on an M3 Max; two images on iOS), orc1_guard.pyandcb_extent.py(6.5–19 s with a warm memo, ~100–106 s cold), and unlinked the progress file before running the table tools.ShaderWatchalso mapped every step other thancache checkback tocompiling, hidingcompiling RT library. - Fix:
dmsh_build.pynow flushes the final count ofcache checkandcompiling, flushes immediately on every step change, reportscompiling mesh librariesacross_mesh, passes anon_progresscallback throughpublish_librarytoshader_lib.writeforwriting the library image(orwriting the Mac library imageandwriting the iOS library imageon dual-image builds, with file counts and bytes written), and reportsc1 guardanduniform read extentsbefore unlinkingDMSH_PROGRESSat exit.ShaderWatchreadsstep, counts, unit and formatted bytes directly fromDMSH_PROGRESS. - Found on: Ocarina of Time v131072 on an M3 Max (PR #2684). Checked in
dm/tools/tests/test_shader_lib.py(test_write_reports_progress),dm/tools/tests/test_nsp_mac.py(test_shader_watch_follows_all_phases) anddm/tools/tests/test_shader_toolchain_cache.py(BuildProgress).
The split shader tables differ from a game profile's
- Symptom: the shader split stops with
the split shader tables differ from game profile <id>'s, on the game version the profile registers. - Cause: the check compares the split's data rows with the profile's byte for byte, so it stops for either of two reasons: other game files, or a change to
shader_split.pythat reads the same files differently. A profile's tables can only be split again where its game files are, so continuous integration cannot catch the second reason. - Fix: the error shows each differing table's row counts and its first row on each side. For a splitter change, check that the new rows are right, then copy the tables from
shader/pkg.partial/tablesin the build folder into the profile. A change to the splitter's output also needs the other profiles it reaches split again. - Duplicate selection (first four profiles refreshed, 2026-11-17, issues #2916 and #2921):
8d62601fmademainuse the same checked first-copy selection as RomFS, replacing unchecked last-copy selection. The registered executables of Splatoon Raiders, Pokémon Scarlet, Tears of the Kingdom and Donkey Kong Bananza each regenerate 40mainrows: 22 source labels change and 14 more rows change only their package index. Their maps were refreshed with those 36 differing rows and the current source-column header; every registered key, stage and package and every non-mainrow is preserved. The strict table comparison and duplicate-content checks stay unchanged. Bananza's additional DLC shaders still use the existing DLC-only derived profile; they do not belong in its registered base/update map. - Registered representatives: Source labels determine package ordering and indices. When packing a registered build, the splitter prefers the map's occurrence when the same source, key and stage are found, both among shaders collected with
mainand when merging scanned files. It checks duplicate shader payloads before selecting the registered occurrence. The game's copy still takes precedence over a DLC copy, and play captures supply only new shader keys. A missing occurrence falls back to first-copy selection, and the packer checks the generated tables row for row. Standalone splits and new profiles use checked first-copy selection.test_split_representativescovers package order, payloads, missing registered sources and the packing gate. - Further rollout (2026-11-17 to 2026-11-19, issues #2924, #2927, #2946, #2964 and #2950): Odyssey, Breath of the Wild, Wonder, Mario Tennis Fever, Orbitals, Fire Emblem Fortune's Weave, Pokémon Legends: Z-A, Super Smash Bros. Ultimate, Mario Kart World and Final Fantasy XII The Zodiac Age have verified representative refreshes. Their notes record the checks and limits.
- Found on: Duplicate source labels occurred in the executable scan for Echoes of Wisdom and across RomFS files for Fast Fusion. In Splatoon Raiders (issue #1263), NVN2 task and mesh shaders moved one row from vertex to mesh. Donkey Kong Bananza, Pokemon Pokopia and Hyrule Warriors: Age of Imprisonment were checked and hold no such shader; Fire Emblem Fortune's Weave was not checked, as no dump was at hand.
TT Games shaders are missing from the executable and DAT archives
- Symptom: a provisional build of LEGO Star Wars: The Skywalker Saga reports loose control sections with no code area and misses the shaders in its
.nnx_shadersmembers. - Cause: some control sections have neither a relocated code pointer nor a nearby instruction constructing one. Headerless compute code also makes both adjacent ranges look plausible by length alone. The remaining shaders live in TT Games' CC4 v2 DAT indices, which the splitter did not read.
- Fix: keep reference-based matches first, then take a unique adjacent code area. When multiple ranges fit a headerless compute shader, use Maxwell scheduling words and an
EXITin an instruction slot to distinguish them. For embedded vertex and fragment assembly, the splitter also recognizes a nearby copy of headed code when the stage and byte count passed to the call agree and the control reference is in the same straight-line sequence. Ambiguous candidates stay unselected.ttdat.pyreads the bounded index, maps full paths to file records with their FNV-1a hashes, and reads only.nnx_shadersmembers. Older serialized programs keep reflection data between their control section and headed code, searched only up to the next program. OODL members enable the existing Mac host decoder. The splitter reports malformed indices and members through its unreadable-file diagnostics. - Found on: LEGO Star Wars: The Skywalker Saga (
010042D00D900000, 1.10.0, mainec593a5f9552100a9fe95c4ca9e34873), issue #1597. The original PR reports 667 executable shaders and 97,648 RomFS shaders from a fresh split with a provisional profile. The rebase was checked on Advance Wars 1+2: Re-Boot Camp: all 43 executable shaders, including 32 loose Bink programs, match the previous splitter byte for byte.
DFLT shader members in TT Games DLC
- Symptom: the shader split reports
unsupported TT Games compression b'DFLT'and leaves out the affected add-on shaders. - Cause: the CC4 reader handled stored members and OODL chunks. DFLT uses the same 12-byte chunk header with little-endian stored and decoded lengths. Each compressed chunk in the tested DLC holds one final DEFLATE block. The type bits are 0 for dynamic Huffman and 1 for fixed Huffman. Standard DEFLATE expects 2 for dynamic Huffman.
- Fix: interpret the DFLT block type before decoding with zlib. Require the decoder to consume the whole chunk and produce exactly its declared length within the indexed member size.
- Found on: LEGO Star Wars: The Skywalker Saga 1.10.0. All 551 compressed chunks from 83 shader members in 15 DLC archives decode. The full split adds 984 shader keys to the 98,315 from the updated game and reports no unreadable files.
The shader package and the shader map come from different splits
- Symptom:
dmsh_build.pystops with[RED] <package> holds no record of shader <key>, which the shader map names: the package and the map come from different shader_split.py runs, with(its records carry no keys: it was split before they did)for a package from before chain3df44a5a4e0c. Before that chain: wrong shaders wherever the game drew, such as a black screen with sound. - Cause:
dmsh_build.pyrec_ofread a shader's record by its row's index in the map alone. With a package (shader/pkg/*.bin) from one split and a map from a later one that dropped or added a row, every later row of that package was translated from another shader's bytes. The NSP script's own split never mixes them: its reuse key coversshader_split.pyand the profile's tables. A build whose split came from elsewhere could: NX2Apple's patches hand the split to another tool under the same key. - Fix: general, in the package format.
shader_split.pywrites each record's key (its 8 bytes) at record +0x08, in header bytes that were zero;dmsh_build.pyrecord_indexindexes a package by those keys andrec_offinds a row's record by its key, so a row's index no longer matters and a package that does not hold a row's shader stops the build before the first job. The control section is searched from +0x38, after the header. The map keeps its index column, so the profiles' tables did not change. A package from before the change carries no keys: the NSP script splits again by itself (its key coversshader_split.py), while a tool that handsdmsh_build.pyan older package, such asregress.py's use of a game's<id>_build/shader/pkg, needs that build run again first.test_shader_package_keyscovers both sides. - Found on: The Legend of Zelda: Ocarina of Time (issue #1841, diagnosed by its reporter). A build through NX2Apple 1.3.0 kept
ps_lib.binfrom an older split (4,711 records) beside a map from a split after04df08d4(4,707 rows), so the present pass's pixel shader29e3c9dd92b8a571was translated from a terrain shader's record and drew black.
A provisional profile loses its tables to its own derived copy
- Symptom: a shader stage stops with
FileNotFoundError: [Errno 2] No such file or directory: …/profile/<id>/bf_want.tsvright afterthe reader decoded additional compute kernels from this registered build, and the profile folder is left withgame.tsvalone: its shader tables, prewarm list and conflict rulings are gone. - Cause: the build took its own provisional profile for a registered one.
DM_GAMES_DIRreached the build folder'sprofile/(the bring-up recipe the script prints sets it), sogame.pyby_titlefound the provisional profile there andmainpacked it as registered. Steps meant for a registered profile then ran on it: the split's compute-kernel check derived it (derive_profile) into the folder where derived and provisional profiles go,<build folder>/profile/<id>, which was the profile's own folder.derive_profiledeletes that folder's files and then copies the profile's into it, so the copy read files the delete had removed. The heap check, which runs only for a provisional profile, was skipped as well. - Fix: general, in the profile lookup.
own_profile_foldersnames every folder the script writes a game's provisional and derived profiles to (<NSP folder>/<id>_build/profile,<work dir>/profile,--profile-out), andmainleaves them out ofby_titleand ofsame_build'sby_build(theirskip). A provisional profile there is packed as provisional again, with its heap check, and a derived one is derived again from its registered profile.derive_profilestops with aBuildErrorrather than derive a profile onto its own folder. This also covers a multi-program game's provisional profiles that the first program's build put onDM_GAMES_DIR(PR #2503). Tests:test_the_builds_own_profile_is_not_taken_as_registered(test_nsp_work_dir.py) andtest_a_profile_is_never_derived_onto_its_own_folder(test_nsp_incremental.py). - Found on: Chained Echoes (PR #2564), whose provisional profile had additional compute kernels to add. The tables came back from
shader/pkg.partial/tables, and the prewarm list and the conflict rulings from their empty defaults.
A reuse build spends a minute and a half on the c1 and uniform extent tables
- Symptom: a build that restores every shader from the compile cache still spends about a minute and a half after the last shader, with the progress line at 99%, before
dmsh_build.pyprintsc1_full.tsv: …andcb_extent.tsv: …: 95 s for Ocarina of Time's 42,848 shaders on an M3 Max. - Cause:
c1_guard.pyandcb_extent.pyanalysed every shader's MSL and reflection again after each full build (dmsh_build.pyruns them, andchain_tableswhen a table names another library), though a shader restored from the cache has the same files, so the same answer. - Fix: with
DMSH_TABLE_MEMOset to a folder, each tool keeps a line per shader there (c1_guard.memo,cb_extent.memo): the SHA-256 of the files it read, then its answer. The next run takes the answer of every shader whose files hash the same and analyses the rest. The NSP script sets it to its shader cache folder for the build and forchain_tables. The memo's first line is a fingerprint ofc1_guard.py,cb_extent.py,dmsh_abi.pyand the header it reads (dm/gfx/nvn/dmsh_abi.h: the binding kindscb_extent.pyfilters on), so an edit to any of them starts it empty. It holds the last run's answers only (6.5 MB for Ocarina of Time). Without the variable nothing is hashed. - Found on: Ocarina of Time v131072 on an M3 Max: both tables in 95.1 s without the memo, 96.8 s with an empty one and 6.5 s from a full one, byte-identical after the header in all three runs.
dm/tools/tests/test_nsp_chain.py(TableTools: the same tables from the memo, its answer used, changed bytes analysed again, another version's memo not taken).
A cold build spends half a minute on the c1 and uniform extent tables
-
Symptom: after the last shader of a cold full build,
dmsh_build.pykeeps every core busy for about another half minute before it printsc1_full.tsv: …andcb_extent.tsv: …: Tears of the Kingdom's 28,669 shaders on an M5 Pro, 33 s of a 507 s build when the build runs them. The tools alone on a finished library: 27 s, and 14 s for Breath of the Wild. -
Cause:
c1_guard.pyandcb_extent.pyspent their time in patterns over each shader's whole MSL. The interval arithmetic was 1% of it.definitions_ofscanned every shader with a c1 read or a bounded uniform read for its temporaries: the declarations twice, the assignments once. It was 85% ofc1_guard.pyand 52% ofcb_extent.py. Most indices are literals and ask for no definition: of 484 sampled shaders with a c1 read, 11 have a temporary in an index.ASSIGNMENTstarts with a lookbehind or an alternation, andcb_extent.pyran two patterns that start with\bfor each binding of each shader (45% of its time).retries such a pattern at every character (Rewrites that try every character of a large source).
-
Fix: the same answers from less scanning, in the two tools.
Definitionsmakesdefinitions_ofwhenIntervalfirst looks a temporary up.definitions_ofcounts the declarations in the scan that collects them. It finds the assignments withASSIGNED,ASSIGNMENT's first form with its literal first, when the text has no++and no--: the other two forms need one. A text with one takesASSIGNMENTas before.cb_extent.pyuses_ofcounts a binding's uses and its declaration withstr.findand the characters on both sides.- The memo's fingerprint covers both tools, so the first build after this fills the memo again.
-
Measurement: M5 Pro (18 cores), Python 3.13, the Mac library image, no memo, the two tools one after the other as the build runs them, best of three.
Both tools, wall (CPU) Before After Tears of the Kingdom, 28,669 shaders 26.7 s (458 s) 5.0 s (79 s) Breath of the Wild, 19,592 14.3 s (241 s) 3.0 s (45 s) Pokémon Scarlet, 30,142 24.2 s (417 s) 4.8 s (76 s) A whole cold Mac build of Tears of the Kingdom, one run each: 507.1 to 490.9 s. The two tools inside it: 33.3 s (543 s of CPU) to 10.5 s (109 s). The rest of the build, the same work in both, took 473.8 and 480.4 s.
Both tables of the three games are the same line for line after the header, which holds the time of the run, and so are the two whole builds' tables.
-
Open:
- Reading a vertex shader's body once was measured and not taken. Its MSL holds
main0's body inmain0,main0_zandmain0_gs, and the copies are 55% of a library's text. Dropping them halves the unchanged tools (26.7 to 13.3 s) and saves 1.4 s after this change (5.0 to 3.6 s), for a check of the three entry points' forms. - The memo (A reuse build spends a minute and a half on the c1 and uniform extent tables) no longer gains on these games: a run from a full memo is 4.9 s for Tears of the Kingdom, since every file is still read and hashed. Not measured on Ocarina of Time, which the memo was written for.
ACCESSalso starts with\band is most of whatc1_guard.pystill costs.
- Reading a vertex shader's body once was measured and not taken. Its MSL holds
-
Found on: Tears of the Kingdom, in a profile of its cold Mac build.
-
Check:
dm/gfx/tests/test_table_scans.py: the assignment scan against the plain one, definitions made only for a temporary,uses_ofagainst the two patterns.
Every second build signs the whole Mac app again
- Symptom: a build's last stage shows
Mac app · game fileswithout(reused, signed)and signs for three minutes, though the game files did not change and the build before it showedgame files (reused, signed); a build that changed nothing still showsMac app · pipeline archiveand signs for half a minute. Ocarina of Time (a 36 GB app) on an M3 Max:Mac apptook 3:33 in the build after one where it took 1:11, and four packs that each changed one small file took 8 s, 220 s, 8 s and 220 s. - Cause: three things kept
pack_app.pyfrom finding a data bundle as its last pack left it. A bundle cloned from the app being replaced has the change time of its files moved by macOS a second to a minute after the pack (seen on macOS 27.2 on APFS, as Spotlight takes in the new app; not in a.noindexfolder, and not for the files that are clones of the build folder's), so the record a pack wrote after reusing a bundle never matched at the next pack, and reuse alternated. It moves the change times of the build folder's large files as well (the 10.7 GB library image, 6 and 19 minutes after its build), which the packer keys those inputs by, so a build that changed nothing made the shader libraries' bundle again. The prewarm pipelines inpso/macwere taken away by eachpso_offline.pyrun (as archives of an architecture not asked for) and linked again by the NSP script, andpso_offline.pywroteprebuilt.tsvandarchive.tsvagain with the same text: new times for files the packer keys by their times, so the pipeline archive bundle was made and signed by every build. And a pack that stopped (while it signed, the long step) had already deleted<app>.key, so the next pack signed every bundle though the app in place was unchanged. - Fix:
<app>.keyalso records a SHA-256 for each file of the data bundles (seals): the digest its bundle's signature holds (CodeResources,files2), which codesign wrote from the bytes it read, and for the few small files the signature does not name (the bundle'sInfo.plist, the signature's own) their own. A file whose change time alone differs from the record is read and compared with it (as_recorded): the same bytes are reused (and the app's record is written again with the new times), other bytes or a file with no recorded digest make the bundle anew as before. The large inputs are taken the same way (as_packed, the record'ssources: the app's copy's digest for the RomFS image and the archive's files, which are clones, and the library image's own, read while its bundle is filled). The NSP script leaves a prewarm file inpso/macthat is already this build's (the same link, or a copy of the same bytes),pso_offline.pyleaves an asked architecture's prewarm files and a list whose text is unchanged, and a pack that fails sets its record aside as<app>.key.replaced, from which the next pack takes only the data bundles. The new data bundles are signed at once, each by its own codesign. - Found on: Ocarina of Time v131072 on an M3 Max: the four packs took 8 to 9 s each; the
Mac appstage of a build that changed nothing went from 0:39 to 0:01, and of a build after a chain change from 3:33 (4:02 the same day) to 1:00, the shader libraries and the pipeline archive signed together in 34 s (70 s one after the other, 38 s at once, the same signatures); with the change times of the RomFS image, the library image and the archive moved, the app isreused (inputs unchanged)after 22 s of reading them, where all three bundles were made again before; the app verifies (codesign --verify --strict), and its files are those of the app built before, but for the chain label, the host and the prewarm pipelines.dm/tools/tests/test_nsp_mac_app.py(PackReuse: a moved change time with the packed bytes and with other bytes, a stopped pack;Sign;App: codesign's own record of a large file;Script: the prewarm files left in place),dm/tools/tests/test_pso_offline.py.
A build that changes nothing takes a minute and three quarters
- Symptom: a build whose every stage says
reused (inputs unchanged)still takes 1:45 (Ocarina of Time on an M3 Max): 22 s betweenunpackandrewrite, 12 s inMac shaders · checking the inputs, 26 s inPipeline archive, 39 s inMac app. - Cause: each of them read the game or its libraries again to find them unchanged.
profile_guess.py build_sourcesreads the head of every file of the RomFS, several times over, to say how the shaders are got (19 s for 186,583 files). The shader step's reuse path prunes the compile cache, andprune_shadersread every per-shader entry's size along with its name, which walks the blob table of an 11.5 GB file (13 s) though nothing was to go.pso_offline.pyread every reflection and hashed every library its bases name (33,365 bases) before its key could say the archive was reused. The app was packed again for the reasons of Every second build signs the whole Mac app again. - Fix: the NSP script keeps
build_sources' answer beside the image (RomFS.img.sources) while the image's size and time, the code modules, the module list and the readers are the same, ascheck_formatskeeps its own.prune_shadersreads names and times from the entry table and sizes only for what it removes.pso_offline.pykeeps a key of what a run reads by name and time (run.keyin its work folder: the library image's place, inode, size, modification and change times, the lists, the compiler, the options and the tools' code) with the state of its outputs, and a run with the same key and outputs returns before it reads a library; a library in a folder, or any difference, goes througharchive_keyas before. The inode and change time also catch changed shader bytes whose modification time was preserved. - Found on: Ocarina of Time v131072 on an M3 Max: 1:45 to 0:10, three builds in a row, the app
reused (inputs unchanged); the first build with the new tools took 1:10.
After a chain change the steps behind the last shader take three minutes
- Symptom: a build after a chain change that left the MSL as it was (
Metal cache: mac 55482 reused, 0 compiled) spends about a minute inwriting the library imageand a minute and a half in the c1 and uniform extent tables, and its app step half a minute inshader libraries(Ocarina of Time, 42,848 shaders: 0:56, 1:26 and 0:25 on an M3 Max). - Cause: the tables' memo (A reuse build spends a minute and a half on the c1 and uniform extent tables) is keyed by each shader's files, and a reflection names its chain version, which neither tool reads: after a chain change every key missed.
dmsh_build.pywrites the image from its 300,000 staged outputs, read out of the compile cache one after the other on one SQLite connection, which gives a library's chain of pages at about 190 MB/s; the app's copy of the library (shader_lib.subset) read its 130,000 files one by one too. - Fix: the memo's key takes a reflection without its chain version (
memo_reflection).shader_lib.writecalls the sources it is given as functions on eight threads, a few entries ahead of the writer, which takes them in order, andshader_cache.Store.getreads on a read-only connection of the calling thread's own when that thread is not the one that opened the store and is not inside a batch (it takes the store's lock to ask, so a batch under way in another thread is over first, as before);subsetreads its files the same way, andpso_offline.pyhashes the libraries on eight threads. The connections have a reader-lifetime guard during recovery and close. - Found on: Ocarina of Time v131072 on an M3 Max: both tables in 106 s with an empty memo, 6.6 s from a full one and 13 to 19 s in the builds after a chain change (86 to 104 s before), their rows the same; the image in 40 to 49 s (56 to 70 s before; 7.4 GB from the cache in 22.3 s against 48.8 s alone), the app's copy in 15 s against 23 s, the same bytes each time; every file of the library is the one the unchanged tools built, but for the chain label.
dm/tools/tests/test_nsp_chain.py(test_memo_holds_across_a_chain_change),dm/tools/tests/test_shader_lib.py(Write),dm/tools/tests/test_shader_cache.py.
Cache recovery races a parallel shader reader
- Symptom: a shader build stops with an uncaught
KeyErrorinStore._readerwhile the damaged compile cache is being recreated. - Cause: the parallel reader checked and returned its registry entry outside the store lock, so recovery could clear that entry before the lookup. Connection creation also ran outside the lock, allowing a reader of the old file to be registered after recovery replaced it, and recovery could close a connection during an active
fetchall. - Fix:
shader_cache.Store._readercreates, registers and reserves a connection under the store lock, then keeps its own query lock untilfetchallfinishes. Recovery and close retire readers under the same registry lock and wait for active queries before closing their connections. A failed query releases its reservation before returning to the primary connection, preserving the lock order; independent readers still execute in parallel. - Found on: no game; reproduced with synthetic caches during the review of PR #2820.
test_shader_cache.Entriespauses opening, fetching and a failed query during recovery, checks the recreated cache remains readable, and requires two independent queries to enter SQLite together.
A changed shader library reuses an old pipeline archive
- Symptom: replacing a shader-library image with different bytes of the same size while preserving its modification time leaves the old pipeline archive reused without reading the changed libraries.
- Cause:
pso_offline.run_keyrecorded only the image's path, size and modification time. That identity could remain unchanged after a timestamp-preserving write or replacement, bypassing the content-basedarchive_key. - Fix: the fast key also records the inode and change time, as the image reader does (
romfs._resolve), and its format is version 2. A changed identity goes througharchive_key, which hashes the libraries' bytes; an unchanged image still takes the fast path. - Found on: no game; reproduced with synthetic libraries during the review of PR #2820.
test_pso_offline.Build.test_a_changed_image_with_preserved_size_and_mtime_is_read_againchanges used metallib bytes inside a valid image, restores its modification time, and checks that the compiler is called again before subsequent unchanged runs are reused.
The free-space check stops a build on a Mac that has the space
- Symptom: the NSP script stops with
[RED] less than N GB free on the volume of <build folder>before extraction (orless than 5 GB freebefore the IPA), while Finder and the Storage settings show far more available. The Mac app step can stop withthe app needs … GB on the volume of …, andpso_offline.pywithGB free on the volume of …, metal-tt needs about …orGB free before merging. - Cause: every check read
shutil.disk_usage(statvfs), which counts only unallocated blocks. On APFS, space held by purgeable data (local Time Machine snapshots, caches the system deletes on demand) is not in it, though macOS frees that space while a write needs it. - Fix:
dm/tools/vol_space.pyfree_bytesreturns macOS'skCFURLVolumeAvailableCapacityForImportantUsageKeyfor the path's volume (the capacity for writes a user asked for, queried through CoreFoundation), never less thanstatvfs's figure, andstatvfsalone where macOS gives none. It asks the nearest existing folder of a path not made yet. The NSP script'sfree_gb,pack_app.py's copy check andpso_offline.py's checks beforemetal-ttand before the merge use it. Two reads keepstatvfs:tree_tar.pack_quiet, housekeeping nobody asked for, which should make macOS purge nothing, andpso_offline.py's diagnosis of a failedmetal-tt, which reports what was really left. Tests:dm/tools/tests/test_vol_space.py. - Found on: a user's APFS volume with a local Time Machine snapshot holding over 50 GB of deleted files (PR #2257):
statvfsshowed 18.84 GiB free and the capacity for important usage 68.02 GiB. With the capacity, an Ocarina of Time v131072--platform mac-appbuild wrote 57 GB of work and a 35.2 GB app there, with 24 GiB still unallocated at the end. Applies to every game built on a Mac.
The shader split takes a minute on a RomFS of 300,000 files
- Symptom: the NSP script's
shader splitstep takes 60 to 77 s for Tears of the Kingdom on an M5 Pro.shader_split.pyprints nothing for its first 26 s, then itsprogress: n/304243count slows after the first half. - Cause: only 1,683 of the 304,243 files hold a shader container, and parsing and de-duplicating shaders took under 1% of worker time. The CRA, zip, PDAT and RPF6 finders made 1.2 million opens in the parent process (22.9 of the 26.4 s before the scan).
unzsalso startedzstdfor each of 32,176 files without a dictionary, 39% of worker time. Image opens themselves added contention (Processes that scan one RomFS image in parallel wait on its opens). - Fix: the pool reads the first eight bytes of each file in batches. The CRA, zip, PDAT and RPF6 finders validate the candidates selected by their first four bytes. The EA finder uses the same read and matches its four- and eight-byte signatures.
unzsdecodes all zstd frames in process, using the existing dictionary lookup when a dictionary is named. The separate Next Level Games decoder still uses the command. - Measurement: the original PR measured a cold split on an 18-core M5 Pro, Python 3.13, with
J=18. Tears of the Kingdom 1.4.3 went from 60.0 s (528 s CPU) to 17.5 s (215 s CPU) with both optimizations. Its split inside a cold pack went from 70.6 to 21.9 s. Breath of the Wild went from 70.1 to 67.1 s and Pokémon Scarlet stayed at 10.4 s. The package files and all four tables were byte-identical in all three comparisons on the PR base. - Found on: Tears of the Kingdom, while profiling the shader split.
- Check:
test_split_magics.pysplits an image with a renamed zip, an eight-byte EA signature and concatenated zstd frames with an emptyPATH.test_easf.pycovers EA's version keys and DLC routing.
Diagnostic reports
A large log can retain key material after redaction
- Symptom:
scripts/bug_report.pycan include key material from a log larger than 4 MB in the report zip, despite removing the same key line from a smaller log. - Cause:
read_textkept fixed byte windows beforeredactmatched key lines. The first window could end partway through a value, below the matcher’s 32-hex-digit threshold; the last could start after the key name. Neither fragment was recognized as a key line. Whitespace before a detached value can also keep it inside the bundle’s final byte cap. - Fix: keep only complete lines at the two read boundaries before redaction, using the byte before the tail to distinguish a complete first line from a fragment. The omitted-byte count includes the discarded fragments; reading stays bounded. Files within the limit and a complete final line without a newline are unchanged.
- Found on: synthetic logs in
dm/tools/tests/test_bug_report.py, including a key value surviving in the final zip on the old code. No game files or real keys are needed; this is a diagnostic collector finding, not a game-runtime failure.
IPA archives
AltServer cannot install a file of 2 GiB or more
- Symptom: AltServer stops installing an IPA with "The file “b-.img” couldn’t be saved in the folder “msl”", although the RomFS stays out of it (
--romfs separate). Other install tools install the same IPA. - Cause: in AltServer, not here. Its
writeFile(AltServer/Devices/ALTDeviceManager.mm) reads a file whole and hands it to oneafc_file_write, which libimobiledevice sends with onesend()and returns its result as anint, so a file of 2^31 bytes or more fails, and AltServer reports the short write as a file it could not save. A shader library is one file,msl/b-<chain>.img(Shader libraries take a file per shader variant); a bundled RomFS image or a DLC image that large fails the same way. - Fix: a workaround, as the limit is the install tool's, and opt-in:
SHADER_FILES = Trueor--shader-filesin the NSP script (DM_SHADER_FILES=1forbuild_ipa.sh,pack_ipa.py --shader-files) packs the shader library as its separate files,msl/b-<chain>/, whatever its size. What the app carries of the image (after the build's exclusions) is written into a folder beside the IPA for the length of the pack, and the host reads a library folder before an image (nvn_mtl.m,msl_data). The game files still need--romfs separatewhen their image is that large. It is off by default: other install tools take large files, and one file installs faster than tens of thousands. The folder is written and deflated again at every pack, as its files are new each time. - Found on: Tears of the Kingdom 1.4.3, whose library is 2.10 GiB (issue #1688, PR #1697). The cause is read from AltServer's and libimobiledevice's source; an install through AltServer with
--shader-fileshas not been run.
A streamed file changes size and the IPA fails its CRC check
- Symptom: packing succeeds, but
unzip -tor Python'sZipFile.testzip()reports a bad CRC for a large deflated file. - Cause:
pack_ipa.pywrote the uncompressed size collected before reading. Its streaming check compared the output size only for stored files, so a compressible file that grew or shrank still published an archive with the old size. - Fix: count uncompressed bytes as they are read and compare them with the listed size before completing either streamed method. A mismatch stops the pack and removes the partial archive, preserving the previous IPA and its reuse index. Regression tests cover growth and shrinkage with both deflate and store.
- Found on: synthetic IPA inputs while reviewing PR #279; no game files required.
RomFS images
RomFS folder transfers fail or leave stale game files
- Symptom:
devicectlcopying a large RomFS folder fails with POSIX error 24 (EMFILE) or spends most of its time on small files; deleting an old folder during iOS startup hits the launch watchdog. A push after changing extracted files can also keep sending old assets if an image is reused solely because it exists. - Cause: a folder transfer performs hundreds of thousands of file operations. The image cache must track its source tree, and magic plus total length cannot establish that an image's index is valid. Accepting that weak check before deleting the working folder loses the fallback when mounting later rejects the index.
- Fix:
dm/tools/romfs_image.pypacks oneDMROMFS1file: a 32-byte header, file bytes, then the index and name pool. Each directory has a sorted, contiguous run of child entries; the host binary-searches each path component and reads file ranges withpreadthrough one descriptor per mount. Overlay folders keep precedence and directory listings merge both sources. The shareddm/host/romfs_image.hloader checks the full index before either mounting or iOS folder cleanup: length, entry and name bounds, file ranges, a rooted breadth-first directory tree, and sorted, unique child names. It supports an empty root too. Invalid images fall back to the folders on iOS; an explicit invalidDM_ROMFSimage is refused with a[RED]line. The index check detects interrupted sequential transfers and structural damage, not same-length corruption inside file contents. The packer publishes by rename only after the source stays stable. Its reuse stamp tracks source names and file metadata including ctime, the packer and image identity; the push helper always checks it, and--repackforces a rebuild. Usage: Quick reinstalls. - Found on: Tears of the Kingdom, whose 304,000-file transfer and startup deletion failures are reported in PR #369. ANIMAL WELL provides the empty-image boot case. Synthetic packer/host tests cover actual file reads, case aliases, overlay merging, corrupt indexes and changed sources; the macOS Foundation test executes iOS's locator to check that rejected images preserve its folder.
devicectl copies a large RomFS image through the Mac's memory
- Symptom:
scripts/push_romfs.shstops after a few seconds to two minutes withThe connection was interrupted(com.apple.dt.CoreDeviceError error 3,com.apple.Mercury.error error 1000) and leaves a 0 KBDocuments/romfs.img; retries fail the same way. Meanwhile macOS says the system has run out of application memory although little RAM is in use:sysctl vm.swapusageshows the swap nearly full, andtop -o memshowsCoreDeviceServiceholding tens of GB, nearly all of it compressed. Neither the device's lock state nor its free space is the cause. - Cause:
xcrun devicectl device copy tohas the Mac'sCoreDeviceServiceread the whole source file into its own memory. A 26 GB image grew the service to 25–27 GB within about 30 s; on a 16 GB Mac whose nearly full internal disk could not grow the swap past 27.6 GB, the system killed the service (it started again the second the copy failed, with no crash report), anddevicectllost its connection. The memory stays held while the service lives: killing it (launchd starts it again on demand) let the swap fall from 27 to 4 GB. App installs (devicectl device install app) take another path and stream: an app holding one 8 GB shader image installed with no such growth. - Fix:
push_romfs.shsends the image over AFC (house_arrest, the channel of Finder's file sharing; the app setsUIFileSharingEnabled) with libimobiledevice'safcclient --container <bundle ID>, toDocuments/romfs.img.part, whichmain.mnever takes, and renames it toromfs.imgonce the device holds all of it.afcclientexits 0 even when a command fails, so the script compares the size on the device (afcclient info) with the image's: a cut-off copy stops it with a[RED]line and leaves the oldromfs.imgas it was. Before copying, the script checks thatafcclientopens the app'sDocuments: it finds a device only by its UDID over USB, wheredevicectlalso takes its own identifier, the device's name and Wi-Fi, so a wrong ID or a Wi-Fi-only device gets a[RED]line saying so.afcclientstayed at 12 MB while sending, about 33 MB/s to an M1 iPad over USB-C. Withoutafcclient(brew install libimobiledevice) the script copies throughdevicectlonly an image smaller than half the Mac's memory, and says how to install it;ROMFS_PUSH_VIA=afc/devicectlchooses either.dm/tools/tests/test_romfs_image.py(AfcTransfers) runs the script against a fakeafcclient. - Found on: The Legend of Zelda: Ocarina of Time (a 26.2 GB image, an iPad Pro 11-inch 3rd generation, a 16 GB M4 MacBook Air, macOS 27.2, CoreDevice 651.32; 2026-11-08): six
devicectlpushes failed. Every game whose image is larger than the Mac's free memory and swap is affected.
devicectl's --remove-existing-content empties the app's whole container
- Symptom: after
scripts/push_romfs.sh <device> <bundle ID> <resources.env>the game files are gone from the device, and so are the saves:Documentsis empty, andDocuments,Library,SystemDataandtmpall carry the time of the push. The script stopped withERROR: Failed to retrieve the file node for Documents/aoc (com.apple.dt.CoreDeviceError error 7000)after the image had been copied. - Cause: the script replaced the DLC folder with
xcrun devicectl device copy to … --destination Documents/aoc --remove-existing-content true, from an empty folder when the build has no DLC. On CoreDevice 651.32 (macOS 27.2, an iPad on iPadOS 27.0.1) that empties the app's whole data container, whetherDocuments/aocexists or not, and then fails with the error above: a test file inDocumentsand a folder inLibrarywere gone afterwards, and every folder of the container had been made again. Every push from aresources.envran it, for every game. - Fix: the script replaces
Documents/aocover AFC only (afcclient … rm -rf /Documents/aoc,mkdir, then aput -r -fof each DLC item, each checked withafcclient info, asafcclientexits 0 when a command fails) and never passes--remove-existing-content. Withoutafcclientit leavesDocuments/aocas it is when the build has no DLC, and stops with a[RED]line, after the image, when it has some.dm/tools/tests/test_romfs_image.py(DlcTransfers) checks that a save and the app's preferences survive both a DLC set and an empty one, and thatdevicectlis never given the flag. - Found on: The Legend of Zelda: Ocarina of Time (2026-11-08): the first complete AFC copy of its 26.2 GB image was deleted by the DLC step that followed it; reproduced twice with test files (with
Documents/aocmissing and present). The app held no save yet.
A reboot packs a RomFS image again
- Symptom: the first build after restarting the Mac spends minutes in
unpack([1/5] unpack v131072: 5%, 1.2/~24.4 GB) although the game, the packer and the image are as they were: 8 minutes for a 24.4 GB image from a NUP on a network share. - Cause: the stamp beside an image (
RomFS.img.inputs.json) heldst_devin the image's identity, and macOS numbers a volume when it mounts it. Across one reboot the Data volume went from 16777234 to 16777232 while inode, size and both times stayed, soreusable()refused every game's image at once. - Fix:
file_identityleavesst_devout, as the IPA and app packers' stamps already did. Inode, size, modification and change times still catch an image replaced or written over. An old stamp still misses the fast check, so the NUP packer verifies the existing image before repacking. - Found on: Ocarina of Time (Switch 2,
0400486024DEC000, packed from a NUP; PR #1299); the stamps of Star Fox and Mario Kart World show the same two numbers.dm/tools/tests/test_romfs_image.pyremounts an image under another device number.
An old NUP cache stamp makes the build unpack again
- Symptom: the next build spends minutes unpacking a NUP after a packer update even though its complete
RomFS.imgis still present. - Cause: the stamp's digest holds the packers' source (
romfs_image.pyandpack_nup.py), and its identity has the fieldsfile_identitygives; a change to either misses the fast check for every image, though neither says the image's bytes changed. - Fix: on a stamp miss,
pack_nup.verifiedcompares the existing image with what the packer would write now: its size, its header and index asromfs_image.layoutmakes them (the byteswritewrites, so a change of format still packs again), and each file's bytes against the SHA-256 in the NUP's table of contents. Only the image is read, not the NUP's file data. If the image is the same before and after the check, its stamp is renewed and later builds take the fast check; otherwise it is packed again. The build's unpack line ends inreused (image checked). - Found on: Ocarina of Time v131072 (PR #1630): the 26.25 GB image took 21.6 s to check on an Apple M1 and 0.1 s to reuse on the next build, against minutes to unpack.
dm/tools/tests/test_nsp_nup.py(ImageReuse) covers an old stamp, a damaged file, a wrong index, a cut-off image, an image changed during the check and an older layout.
A commit switched and back, or another worktree, rebuilds every shader
- Symptom: a build after
git checkoutto another commit and back, or from another worktree of the same repository, with the translator's bytes as they were, translates every shader again:building the whole shader map, 42,848 shadersand 46 minutes for Ocarina of Time's Mac shaders, all from the compile cache, wherereused (inputs unchanged)was expected. - Cause: the shader step's reuse key (
build_shaders) took the translator by where it was and when it was written: its folderdm/gfx/tools/dmsh_xlate_binas path, size and modification time (('stat', ...)infingerprint), from when the translator was a folder of .NET binaries, and its path (str(xlate)). Git writes a file again whenever a checkout moves between commits where it differs, and the translator differs between most chain versions, so going and coming back gave the same bytes a new time; another worktree has another path. Either missed the key, and the step removes its key and builds again. - Fix:
scripts/build_ipa_from_nsp.py: the key takes the translator by its bytes alone (translator_key:('files', [xlate])), as it takes the chain's other tools. It is one native executable that links only system libraries, 7.9 MB: 3 to 5 ms to hash. The other('stat', ...)inputs are extracted or provisional game files, too large to read for a key, and stay as they are. The key's form changed, so each game's first shader step after the fix translates again once. - Found on: Ocarina of Time, its Mac app build after the checkout went to a newer
mainand back while the build ran (PR #2496).dm/tools/tests/test_nsp_chain.py(TranslatorKey) takesbuild_shaders' key with the translator rewritten with the same bytes and a new time, at another checkout's path (key kept) and with other bytes (key changed).
A stale DM_ROMFS path crashes the game soon after nnMain
- Symptom: a direct
dmhostrun logsfs mount rom: → <path> (read-only)for a path that does not exist, then crashes in the game's code a fraction of a second afternnMain(Echoes of Wisdom:CRASH sig=11 addr=0x880.3 s in). The host now stops at the mount instead withFATAL the game files <path> (rom:) are missing: neither a folder nor a RomFS image. - Cause: an old run command still named the extraction's
RomFSfolder after a rebuild replaced it withRomFS.img(RomFS folder transfers). The read-only mount accepted any path, so every read failed and the game used the missing data. The iOS app and the Mac app launcher check their game files before they start the host; direct runs had no such check. - Fix:
mount_ex(dm/host/hle_fs.c) stops on a read-only, non-save mount whose path is neither a folder nor a regular file, with the samestatthat tells an image from a folder. Add-on content and system data check their paths before mounting, so only the rom mount (DM_ROMFS, or$DM_ROOT/romfswhen it is unset) reaches it.dm/host/tests/t_fs.cchecks a missing path and a fifo in a forked child. - Found on: Echoes of Wisdom 1.1.0 on the Mac (issue #615, PR #616).
Separate RomFS deployment loses its image or folder fallback
- Symptom: a successful
--romfs separate --no-keep-extractedbuild prints a push command pointing at deleted game files. On iOS, a complete image for another build can also prevent startup despite a validDocuments/romfsfolder. - Cause: separate mode omitted the extraction-retention check, so normal post-build cleanup deleted the image needed for transfer. The startup identity rejection returned before the existing folder lookup.
- Fix: reject separate mode without
--keep-extractedbefore extraction or building. Reject a mismatching image while continuing to the validated folder fallback; move a folder aside for deletion only after accepting the image. Matching images and the default bundled route retain their behavior. The identity covers image size, header and index, not same-length file-content changes. - Found on: synthetic CLI and Foundation startup tests while integrating PR #493, after PR #478; no game or device is needed to reproduce either failure.
A hand-copied RomFS.img is not found on iOS
- Symptom: a
--romfs separateapp whose image was copied into its Documents folder by hand (Finder, the Files app, a LiveContainer guest) logsboot: game files not found (Documents/romfs.img, Documents/romfs or <App>/romfs), and a build withromfs.idshows "There is no game file image on this device.", though the complete image is there. Renaming it toromfs.imgmakes the game start. - Cause: the NSP script writes the image as
extract/<version>/RomFS.img, andpush_romfs.shcopies it toDocuments/romfs.img. A hand copy keeps the source's name. The Mac's file system ignores letter case, so the mismatch never shows there, but iOS's does not, andmain.mlooked up only the exactromfs.img. - Fix:
main.m(romfs_document_images) lists Documents forromfs.imgin any letter case,romfs.imgitself first, and takes the first that is complete and passes theromfs.idcheck; a rejected or incomplete one falls through to the next spelling, then to the folders. The identity report, the backup exclusion and the log lines use the names found. Folder names (Documents/romfs) are still matched exactly. - Found on: South Park: The Fractured But Whole 1.05 on an iPhone 15 Pro Max. The Foundation startup test runs the locator on a case-sensitive APFS disk image. Issue #582.
Building creates a full RomFS tree before packing its image
- Symptom: reducing the iPhone transfer to one image still creates thousands of resource files on the Mac, and build scanners require the expanded folder.
- Cause: folder extraction followed by a separate image pack duplicates the work; ordinary filesystem APIs cannot address files inside an image.
- Fix: the NSP pipeline passes
--romfs-imagetonx_extract. LibHac layers the update over the base and checks its integrity while the writer streams file bytes into a temporaryDMROMFS1image, appends the sorted directory index and publishes by rename. ExeFS remains expanded; RomFS and each DLC remain one physical file.dm/tools/romfs.pygives the scanners read-only virtual paths, bounded seeks and archive mappings (Python 3.12+), without changing the process's standard filesystem APIs. The IPA packer maps the physical image toPayload/DmIOS.app/romfs.img; iOS and the Mac launcher validate and mount it in place. Neither installation nor startup expands the resource files. Documents overrides and legacy folder inputs remain supported. A source image is uncompressed; the IPA can deflate it, so file-count reduction does not imply a smaller installed byte count. Full images for separate game versions cannot share unchanged individual files through APFS clones as legacy folder extraction did. - Found on: ANIMAL WELL, whose direct image is an empty root (56 bytes); the local Baba Is You provisional build exercises 6,374 files in a 103,473,292-byte image, 131 shaders and an unsigned IPA containing only the single image entry. Raging Loop supplies Unity resources: all 1,473 source manifest entries match the image, and every registered shader remains in the scan. Synthetic integration tests call the actual LibHac writer, read unaligned archive ranges, and exercise IPA mapping, Xcode staging and bundled-image startup.
A build folder holds hundreds of thousands of small files
- Symptom: a game's
<id>_buildfolder is slow to count, copy or delete: Metroid Dread's held 160,331 files in 48,782 folders, 84,541 of them in the compile cache. - Cause: the compile cache (
shader/cache/cas) keeps a few files per shader, and Xcode's derived data (ipa/build/ios/pkg/dd) over a thousand. Both are needed to make the next build fast, and only while a build runs. The cache has since become one file read in place, and the tar remains for the derived data. - Fix:
dm/tools/tree_tar.pykeeps each as one uncompressed tar beside where the folder was.build_shadersunpacks the cache only whendmsh_build.pywill run, and packs it after pruning; the NSP script does the same for the derived data aroundbuild_ipa.sh. Keeping real folders during the build leavesdmsh_build.py, its chain version and Xcode unchanged. A build folder from before this converts by itself. Restored files keep their times, and Xcode's incremental build holds across the round trip (1 file compiled, against 262 for a full build). A build that stops leaves the folder, and a damaged tar costs only the cache it held.regress.py's chain builds share the cache under the same lock. The cost is time on each build that runs the step, and a cache that no longer shares its libraries' blocks through APFS clones. The shader libraries (b-<chain>) stay folders: the host reads them one by one. - Found on: ANIMAL WELL (the round trip) and Metroid Dread (84,541 cache files: 51 s to pack, 22 s to restore on a T7).
The compile cache was unpacked for each build
- Symptom: a build that runs the shader step writes the compile cache's files back and removes them again, on Skyward Sword HD 24,131 files and 10,150 folders each time, Tears of the Kingdom over 900,000 entries. Removing old entries took up to half an hour on an external drive.
- Cause: the cache was a folder of a few files per shader, read and written by path, so a tar could only hold it between builds.
- Fix:
dm/tools/shader_cache.pykeeps it as one SQLite file,cas.db, whose entries go in and out by name, with nothing unpacked. Bytes are stored by their hash, since a library under its MSL's digest and its shader's digest was one APFS clone.dmsh_build.pyanddmsh_mtlcache.pyuse it directly; a shader's entry is written in one transaction, so a stop leaves all of it or none. Several writers wait for each other:dmsh_build.py's threads share a connection, andregress.py's chain builds share their own per-game file, with read-only reuse of the normal cache. Pruning is a query that gives its pages back. Acas/orcas.tarfrom before this moves in by itself at the next shader step, without unpacking a tar: the Metal compile results come along. The per-shader entries do not, as the change of chain they came with means they cannot hit, and neither do the fetch variants, whose older entries hold their source's file name, so that a fresh compile's bytes differ (regress.pyreports these as changed variants with no change of MSL). A damaged file costs the work it held and is made anew, and a full drive is one[RED]line. A revision from before this keeps its own folder,regress/cas. - Measured on Skyward Sword HD: a 281 MB
cas.tarbecame a 226 MBcas.db, restoring all 2,470 shaders from the cache took 6 s (9 to 13 s with the tar), and the build folder'sshader/holds 8 files. It also ran on an exFAT volume, with three processes writing at once. - Found on: Skyward Sword HD.
A GL regression run reports a hang while frames continue
- Symptom:
regress.py checkreportshang (no frame after 72.0 s)and stops before the last scheduled screenshot, although the captured log has later[gl] framelines and the thread sample shows the game drawing and swapping normally. - Cause: the watchdog read only the display link's periodic
presents Nmessages for GL games. Those messages stop while the present path falls back to timed presents; the game's GL frame counter keeps advancing. - Fix:
run_watchedaccepts[gl] frame N:as progress too, preserving the present messages for older hosts and other graphics layers. The timeout still catches a game whose frame counter actually stops. - Check:
test_regress.pydrives the real watchdog with a controlled clock and child-process log: one present message, then continuing GL frames, must finish without a hang. - Found on: Fate/hollow ataraxia REMASTERED (
010070E022546000, provisional profile), during the GL argument-buffer regression check: the watchdog stopped at its last display-link record, frame 4200, while the log had reached GL frame 6000.
Regression shader compilations grow the normal build cache
- Symptom: Ocarina of Time's
shader/cache/cas.dboccupies 40.8 GB: 30.4 GB of unique Mac and iOS Metal compilations, two complete generations of 42,848 per-shader records, variants and old staged outputs. Some results are useful for regression tests, but pruning old regression chain libraries does not reclaim their cache entries. - Cause:
regress.pydirected baseline and candidate builders into the normal build's cache. Metal compilations and variants have no retention limit there; per-shader pruning also preserves entries written after the normal library's stamp. - Fix: each game's regression runs share
<id>-work/regress/cas.db.shader_cache.pyreads matching immutable shader, variant and Metal entries from the normal cache through SQLitemode=ro, including committed WAL writes; local entries take precedence, and new outputs, staging and mutable bookkeeping go only into the regression cache. Missing or damaged fallback databases are ignored, never created or repaired. The harness supplies this cache reader to historical SQLite-based builders without changing their shader chain. Its default physical size budget is the larger of 8 GiB and four times the largest shader-library image in the normal build or retained regression chains;--shader-cache-gbsets a fixed per-game budget in GiB. Before and after a build, including a failed or reused build, cleanup removes oldest-written groups until the database fits and returns free pages without copying the database. Shader outputs, variants and split libraries leave as whole groups, identical blobs remain shared, and leftover staging is removed first. Builders hold a shared per-game lock; cleanup requires its exclusive lock, so active builds can temporarily exceed the budget. Folder-based historical builders remain serialized and their legacy archive is removed if it exceeds the budget; the next SQLite-based run adopts it into the regression database. Existing results already mixed into the normal cache stay there: this change does not identify or delete them. - Found on: Ocarina of Time.
- Check:
test_shader_cache.py(read-only fallback, live WAL, forked workers, physical size, grouped eviction, failed builds, concurrent users and a writer without a live harness),test_regress.py(historical builder wiring, shared results across runs, automatic and explicit budgets, reused builds).
Unused files had no one place in the build folder
- Symptom: Ocarina of Time's
run/pso_archiveheld 13.9 GB in 99 files: 64 indexed by library file names (5.3 GB, about 33,700 pipelines, against a prewarm of under 10,000) and 35 with no index (8.4 GB) from the first week. What a build or a run no longer used was deleted in place by some steps, kept by others, and could be told apart from what was in use only by a tool. - Cause: a pipeline's archive key covers its libraries' bytes (
arch_key), so a chain change, a profile edit or an OS update leaves old pipelines no lookup reaches, and only compaction, which takes small files by tier, ever dropped any. The build's own retirements (old libraries, keys, compile caches) were deletions scattered over the build folder. - Fix: one folder,
<id>_build/obsolete/. The NSP script moves what it retires there (retire: old chains' libraries and keys fromprune_stale_chains, other chains' compile caches fromshader_cache.drop_generations) into<date time> build/at their places in the build folder, a rename each. The host counts the pipelines taken from each archive file (arch_lookup,ArchUse), and once a start has asked for the prewarm lists' pipelines and every shader pair's pulling base (the prebuild's walk, after a chain change; or no pairs), moves the files none was taken from into$DM_OBSOLETE/<date time> <archive folder>/(arch_sweep,arch_retire; the Mac run command setsDM_OBSOLETE; the app, without it, removes them), as it already did with files indexed by library file names and files the system cannot open. Both walks are needed for every file, since a run file can hold pulling bases beside bases with a vertex layout. Not in the prebuild's bundle form, nor for files a compaction takes. A file with some live pipelines stays whole: dropping the rest means compacting it, which compiles every pipeline it keeps again (about 85 ms each on Ocarina of Time, 713-762 s for its 8,500 bases), so the sweep only counts them (… indexed files kept, M of their K pipelines taken; F of them under a quarter used (X MB)). Measured on Pokémon Legends: Arceus, its archive from chain 66eab9c9a6b4 under chain 19d183a2b462 (copied run folder, the prebuild tool on an M4 Pro): all 19,449 Metal compiles were byte-identical, so the prebuild took all 9,318 pair bases from the archive in 3.4 s and the line read8 indexed files kept, 9172 of their 9339 pipelines taken; 0 of them under a quarter used (0.0 MB). A chain change mostly leaves the libraries' bytes as they were, so a file's pipelines live or die together, and usage-driven compaction would have freed nothing there: not built. A successful build empties the folder's entries of earlier builds and runs (empty_obsolete), keeps its own until the next one, and logs how much is left. - Found on: Ocarina of Time.
- Check:
test_pso_archive.py(test_unused_file_moved_to_obsolete: two files, a start that takes from one, the other moved with its index once both walks ran),test_nsp_mac.py(test_prune_stale_chains_after_success,test_older_compile_caches_go_with_a_build,test_obsolete_emptied_by_the_next_successful_build). On Ōkami HD's copied run folder, the prebuild tool with a current-chain library moved its archive file from an older chain (0.9 MB) to the obsolete folder and built 41 bases; the next run took all 41 from the archive and moved nothing.
Old chains' compiles stayed in the one compile cache file
- Symptom: Ocarina of Time's
shader/cache/cas.dbgrew to 52 GB, of which its current Mac library used 10.3 GB: about seven generations of Mac Metal compiles (31.4 GB), one of iOS (5.3 GB), three sets of 42,848 per-shader entries (one of them in use), the variants nothing reads sincec8bfa161(2.1 GB) and stopped builds' staging (1.0 GB). What a development build of another chain left could not be told apart or removed without a tool. - Cause: every chain wrote into one file. The Metal compiles (
metallib/) are keyed by the MSL, the convention and the compiler, not by the chain, so no prune could tell which were still wanted, and the NSP script left them all;shader/entries newer than the library's list stayed as well. - Fix: one file per chain version,
shader/cache/cas-<chain>.db(shader_cache.for_chain). A build writes only its own file; another chain's per-shader entries never hit (their digests cover the chain), and a Metal compile it reads from an older file is copied into its own first. After a successful or reused build the NSP script moves the other files whole intoobsolete/(shader_cache.drop_generations, fromprune_shader_cache; Unused files had no one place in the build folder): older chains', andcas.db, the one file of every chain from before, which is the oldest generation. A target the build compiled nothing for (iOS after a Mac-only build, the Mac after an iPhone-only one) first takes the newest other file's compiles of it, and nothing goes while the chain has no file of its own or when copying fails.regress.pyreads the player's generations through--readonly <shader/cache>. A chain change copies the compiles it reuses instead of sharing them, a few GB for a large game, once. - Found on: Ocarina of Time.
- Check:
test_shader_cache.py(Generations: copying on read, newest generation first, other chains' shaders never hit, dropping older files with the other target kept, a folder as the read-only cache),test_nsp_mac.py(test_older_compile_caches_go_with_a_build).
A new compile cache on an exFAT drive is "a readonly database"
- Symptom: the first build of a game whose build folder is on an exFAT drive stops at its shader step, before any shader is compiled:
dmsh_build.pyfails openingshader/cache/cas.dbwithsqlite3.OperationalError: attempt to write a readonly databaseatPRAGMA journal_mode=WALinshader_cache.Store._open, and the step ends with[RED] own_compilers.py exit code 1. Running the build again goes past it, as the failed run has left the file 16 KB long. - Cause: SQLite notes a database file's inode when it opens it and refuses a write once its path names another inode (
SQLITE_READONLY_DBMOVED, extended code 1032, which Python reports as a read-only database); it skips that check while the file is empty. macOS's exFAT driver (FSKit:mountshowsexfat, …, fskit) gives an empty file a placeholder inode (18446744073709551598 on a disk image) and, once it has data, a lasting one. SQLite has guarded against this on Apple systems since 2017: on a volume whose type ismsdosorexfat, it writes one byte (S) into an empty file when it opens it, before it notes the inode. On the reporter's external exFAT drive (macOS 26.6.2) the inode still changed at the first write after the open,PRAGMA auto_vacuumhere, so the WAL pragma after it failed; plain SQLite showed it there too (on a new file,CREATE TABLEthenINSERTfailed at theINSERT). Open: why SQLite's guard missed there (its SQLite build, the drive, or macOS 26's driver). On an exFAT disk image under macOS 27.2, with Apple's SQLite 3.54.0 and 3.54.1 from Homebrew and the tool venv, the guard holds: a new file is 1 byte after the open and keeps its inode, and the cache passes with 400 writes, then 1,200 more from three processes at once. - Fix:
dm/tools/shader_cache.py: whenStore._opengetsSQLITE_READONLY_DBMOVEDwhile it sets the file up, it opens the file again once and finishes, so that SQLite notes the inode the file now keeps. It costs nothing where the error does not come. A file that moves again fails as before. The page size, incremental vacuum and WAL stay as they were. The error's code needs Python 3.11 or newer; an older one fails as before. - Checked:
test_shader_cache.py(Renumbered) gets SQLite's real error by putting a copy of the file in its place after its first write: the store opens the file twice and keeps its settings through 200 writes, and fails as before when the file moves again; withDM_EXFAT_DIRnaming a folder on an exFAT volume, the tests also run there. On the reporter's drive, an earlier form of the fix (a new file always opened again after its header) held 500 entries, then 1,200 more from three processes at once (PR #2435). - Found on: The Legend of Zelda: Ocarina of Time, its first Mac app build from a NUP onto an exFAT drive (GitHub issue #2434). Applies to every game.
Shader libraries take a file per shader variant
- Symptom: a game's shader libraries are slow to copy or delete: Skyward Sword HD's
b-<chain>/held 12,064 files for 2,470 shaders, a third of its build folder's files, and eachregress.pychain build held another set. A tar would not do: the host reads these files at every run. - Cause:
dmsh_build.pywrites each shader's library, reflection, source and side libraries as separate files, and the host opened them by path. - Fix:
dm/tools/shader_lib.pypacks the folder into one file beside its name,b-<chain>.img, in the RomFS image's format, flat, each file's data on 16 bytes. Nothing unpacks it: the host (dm/gfx/nvn/msl_image.h) keeps one descriptor and maps only a shader's pages, and the tools read it throughromfs.py.dmsh_build.pystill writes a folder, so the chain version does not change. The NSP script packs at the end of the shader step, also on a reused step, so a folder from before this converts without a rebuild, and removes the old image only just before a build that replaces it.regress.pypacks each chain build once it has read it; a revision from before this keeps a folder, and has a chain key of its own. The Mac app and the IPA carry the one file, without the Mac's sources, asmsl/b-<chain>.img. An iPhone build keeps the pulling vertex libraries, which the launcher's Metal 4 pipelines and prebuild read on the device (Pulling vertex inputs). An explicitIOS_PULL=0, without an offline archive or Xcode project, neither compiles nor keeps them (DMSH_IOS_PULL=0fordmsh_build.py), sopack_ipa.pyreuses that smaller image between packs. A build that wants them again compiles them, andpack_ipa.pyrefuses an image without them for an app that reads them. Each file comes from a folder beside the image first, so a partialdmsh_build.pyrun (given keys) goes over a packed library, and the next pack takes it in; a host running from a folder goes on when it is packed. Real files remain where a tool needs them: a compile's temporary files, and the librariesmetal-ttreads, for the length of its run.shader_lib.py expandgives an old kept host its folder back. - Measured on Skyward Sword HD, on an external drive, warm cache: 10,017 files to one: copy 3.72 s to 0.18 s, delete 0.40 s to 0.02 s, 150 MB to 131 MB on disk. Reading all 2,470 shaders' reflection and libraries 100 ms to 28 ms. The map must be
MAP_SHARED: on a file this size a private mapping costs about 80 µs, against 0.9 µs. A cold read has not been measured, as the cache cannot be emptied without an administrator. - Found on: Skyward Sword HD.
A Mac app packed with the library's image names it b-<chain>.img.img
- Symptom: the Mac app logs
[RED] shader library …/Contents/Resources/msl/b-<chain> (a folder or a .img file) does not existand thenfailed to load shader. Itsmsl/holdsb-<chain>.img.img, and itsInfo.plistrecordsDMChainas<chain>.img. - Cause:
pack_app.pyaccepts the library's folder path or image path. It used the input filename as the output stem and appended.imgwhen it wrote the image. The NSP script passes the folder path. - Fix: use
shader_lib.name_offor the output stem in the signedShaderLibrariesbundle and in its reuse key, for both the primary program and--programentries. The primary stem still takes the explicit--msl-nameoverride and suppliesDMChain.test_nsp_mac_app.pychecks the signed layout and reuse across both input spellings. - Found on: The Legend of Zelda: Ocarina of Time, a Mac app packed by hand from the build's
shader/cache/b-<chain>.img(PR #1790).
A shader build leaves a file per shader output while it runs or after a stop
- Symptom: a game's build folder holds tens of thousands of small files while its shaders build, and keeps them when the build stops: Octopath Traveler 0's
_build, stopped in its compile, held 68,230 files (38,376 intmp/dmsh_*, 29,757 inshader/cache/b-<chain>/), against 105 once a build finished. Every later build made anothertmp/dmsh_*beside the old one. - Cause:
dmsh_build.pywrote each shader's outputs intob-<chain>/and packed them into the image only at the end (the entry above); its cache check restored every cache hit into that folder before anything was translated; the translator wrote every missed shader's working files (.bin,.spv,.res.json,.metal) into one temporary folder before any was finished; and that folder went only when the build ended normally. - Fix:
dm/gfx/tools/dmsh_build.py. A finished shader's files go into the compile cache (cas-<chain>.db, understage/<output folder>/) and leave the disk (commit); reads of another shader's outputs (a vertex shader's paired pixel MSL forvs_pad, the mesh step) take them from there (output). At the end the image is written from the staged outputs (publish_library, throughshader_lib.write), with a partial build's image under it less the keys it built, and the folder and the staged entries go; when the image cannot be written, the staged outputs go back into the folder. Cache hits are restored when their shader is finished, not at the look. The shaders are translated and finished in batches of 4 ×J(the next batch is translated while this one is finished), each in a folder of its own, and a shader's working files go as soon as it is finished. Each build's working folder holds its process ID; a later build removes admsh_*folder whose process is gone (one without the ID after a day). The NSP script's progress comes from a small file the build rewrites (DMSH_PROGRESS), no longer from counting its files. The outputs are the same: chaincfcc3a82c78bagainst the new one, Minecraft Dungeons II's 61,655 library files and Octopath Traveler 0's 41,880 are byte for byte the same (reflection without itschainfield), apart from_b_cas.txt, which lists the new chain's cache digests. - Measured on an M4 Pro, every shader translated again (the chain changed), the Metal libraries from the cache: Octopath Traveler 0, 10,324 shaders, at most 405 files under
shader/andtmp/(12 outside a build), 2:48 for the step (2:55 with batches of 4 × 128); Minecraft Dungeons II, 15,826 shaders, at most 3,279 with batches of 256 removed whole. Stopped with SIGKILL near the end of a compile: 40 files inb-<chain>/and 7 intmp/dmsh_*; the next run cleared them and wrote the same library from the cache in 59 s. A partial build of 42 shaders for the Mac and the iPhone leaves one image each, also when run again over them. - Found on: Minecraft Dungeons II and Octopath Traveler 0 builds, reported by the user.
A full drive during a shader build drops finished outputs from the library
- Symptom: after a shader build on a nearly full drive (one
[RED] the shader compile cache … cannot be writtenline), the library image lacks some outputs of a shader that built: the host finds no reflection or library for it. - Cause:
commitindmsh_build.pyremoved each file from the disk as soon as its write into the stage had been made, inside the batch that held the shader's other files. SQLite answers a write that does not fit withSQLITE_FULLand may roll the whole transaction back, the writes before it too;Store.putturned the error into itsfullflag, and the files of those earlier writes were neither on disk nor staged, sopublish_libraryleft them out. A later write in the same batch ran outside any transaction and stayed, and a failed commit raised after every file was gone. - Fix:
dm/tools/shader_cache.py: a write or a commit that fails fails its whole batch, which is rolled back withfullset, and no write is tried after that (one inside the ended transaction would land on its own). The outermost batch is tracked by the store, not by SQLite's transaction flag, which the failed write cleared.commitremoves its files only once the batch has committed andfullis still clear; otherwise every file stays on disk, wherepublish_librarytakes it. A forked worker's store (Remote) hasfullfrom the end of its batch.dm/tools/tests/test_shader_cache.pyfills a store with a page limit inside a batch and fails a commit;test_shader_toolchain_cache.pystages a shader into a full store and publishes it. - Found on: a code audit's reproduction with a page-limited SQLite file (2026-11-13); no build has been seen to lose an output.
A work folder holds millions of small files
- Symptom: a game's
<id>-workfolder is too slow to count: Tears of the Kingdom's held 8,893,028 files and 509 GB, and its count ran past ten minutes. - Cause:
regress.pykept one whole shader build per chain version inregress/chain(45 there; Breath of the Wild held 57), and agents' investigations leave folders nothing reads again (buildalone over 351,000 files). - Fix:
prune_chainsinscripts/regress.pyremoves chain builds after each chain step, beyond the 3 used last, any used within 24 hours and those of the 3 newest stored baselines; a check that needs one builds it again.tree_tar.pack_quietpacks each other top-level folder untouched for 14 days, with 100 files or more, into<name>.tarat the end of an NSP script orregress.pyrun. These tars keep extended attributes, so a RomFS folder's case-collision names survive, andtar --xattrs -xfrestores them (plaintar -xfdoes not). A Python virtual environment stays a folder, as scripts run it by its path and nothing writes to it, which made it look untouched. It frees no space beyond the chain builds: a folder of APFS clones can take more as a tar, so each tar must fit with 20 GB to spare. A player's NSP folder has no work folder. - Found on: Tears of the Kingdom.
The zstd command given a path inside the image
- Symptom: the NSP script stops at the shader split of a registered profile with
[RED] 13744 file(s) could not be read, their shaders are left out (first: AI/FileEntry/FileEntry.Product.100.byml.zs: CalledProcessError: Command ['zstd', '-d', '-c', '-q', '…/extract/v0/RomFS.img/AI/…'] returned non-zero exit status 1.). - Cause:
shader_split.py'sunzsread a.zsfile throughromfs.open, which reads inside the image, but then handed its path to thezstdcommand, which can only open real files (Not a directory). - Fix:
unzsinitially fed the command the bytes it read and now decodes zstd in process.test_romfs_read.pychecks a zstd file inside an image. - Found on: Super Mario Bros. Wonder: every file of its RomFS is zstd-compressed, 13,744 left out in both versions; the first image-backed build after the folder extraction.
Under --work-dir the programs of one game overwrote each other's RomFS
- Symptom: an iPhone build of Super Mario 3D All-Stars with
--work-dir(as NX2Apple runs the script) builds every program, then stops at the app build with[RED] missing RomFS marker 'MovieData/BgMovieGalaxy.mp4' in <work dir>/extract/v393216/RomFS.imgandFAIL: no RomFS at …. - Cause: the first program's build packs each of the others from its own profile (
oe::ExecuteProgram), each in its own build folder,<NSP folder>/<id>_build.--work-dirnamed one folder for all of them, so each program'sextract/<version>/RomFS.imgreplaced the one before, and the package found Sunshine's image where the launcher's should be. Without--work-dirthe folders were already apart. - Fix:
build_folderinscripts/build_ipa_from_nsp.pygives a program packed with the first<work dir>/programs/<id>_buildunder--work-dir; the first program, a game of one program and--program Nalone keep the folder as named. Test:test_nsp_build_folder.py. - Found on: Super Mario 3D All-Stars, 1.1.4, built by NX2Apple 1.2.1 as one IPA.
A dump tool's .listing files in the game's folders
- Symptom: a game built from a dump folder crashes in its own code while it loads, where builds from other dumps of the same version play: Nintendo Switch Sports Resort at
main+0x9d7c60, listing itsParameterfolders. - Cause: an FTP dump keeps the server's directory listing as
.listingin every folder, which the NUP spec (§6.3) allows a producer to keep. The RomFS image packed it as a game file, so a game that lists a folder saw one more entry. Switch Sports Resort cuts each name at its first., got an empty name, loadedParameter/<folder>/and found no resource. - Fix:
ARTIFACTSindm/tools/romfs_image.py, the dump-tool files that are not game files (.listing), is left out of the image, out of a NUP's RomFS (scripts/pack_nup.py) and out of the survey's file list (dm/games/profile_guess.py). Other dot files stay game files. Test:test_romfs_image.py(test_dump_tool_listings_are_left_out). - Found on: Nintendo Switch Sports Resort (v65536, from a dump folder).
Processes that scan one RomFS image in parallel wait on its opens
- Symptom: a tool that scans the files of one RomFS image spends much of its time opening them. In Tears of the Kingdom’s shader split, an open took 133 µs with 18 workers, against 28 µs with one.
- Cause: every virtual file read opened the same backing image by path. Workers shared the kernel cost of repeated path resolution and opens of that image.
- Fix:
romfs.reuse_descriptorskeeps a backing descriptor per image for the parent’s archive planning and for the lifetime of each scan worker. The virtual file gets a duplicate for its boundedpreadormmap. It reuses a descriptor only when the image identity still matches. The scan closes the backing descriptors on exit, and the metadata cache owns none. - Measurement: the original PR isolated descriptor reuse on Tears of the Kingdom, with 60.0 → 47.7 s wall time and 528 → 471 s CPU time on an M5 Pro.
- Found on: Tears of the Kingdom, while profiling the shader split.
- Check:
test_romfs_read.pyverifies distinct virtual file descriptors, cleanup after an exception and correct reads after an image is replaced.
Add-on content
Separate DLC for a NUP
- Symptom: a build from a NUP with no embedded DLC omits add-ons the player has as separate RomFS images. The host logs
aoc: reporting 0 add-on contents {} (no DM_AOC_DIR). - Cause: the packing script selected DLC solely from the container. A separately extracted image never reached the shader scan or the app packer.
- Fix:
--aoc-dir <folder>selects a directory of numbered RomFS images for a NUP with no embedded DLC. The script validates the images and stages the complete set separately from the package extraction cache. Each rebuild uses the current selection, including after a front end clears its build folder. An empty folder selects no DLC. A NUP that already lists DLC rejects the option. A prepared Xcode project compares these images by checksum on incremental builds because a replacement can have the same size and whole-second modification time. - Found on: Pokémon Pokopia, v655360, whose marker add-on unlocks data in the update. PR #2905 reports the result on a MacBook Air.
- Check:
test_nsp_nup.pychecks that the selected images reach the build, stale package images stay out, and rebuilds handle replacement, removal and cleanup.test_xcode_workflow.pychecks that the staged app also replaces images with matching sizes and times and removes retired images.
DLC in Documents is ignored or removed DLC remains installed
- Symptom: a game's DLC works only when packed inside its IPA, although its base RomFS can be deployed separately. After pushing a smaller DLC set, removed indices can remain reported as owned and mounted.
- Cause: the iOS launcher originally checked only
<App>/aoc. Merely addingDocuments/aocdiscovery is insufficient:devicectl device copy tomerges directories by default, retaining removed indices, and skipping a build with no DLC leaves the entire previous set behind. The host counts and mounts the numeric entries underDM_AOC_DIR, so those leftovers remain active. - Fix:
aoc_locateindm/ios/Sources/main.mpreserves an explicitDM_AOC_DIRfrom the launch environment orenv.txt; otherwise it selects the first directory atDocuments/aoc, then<App>/aoc, and logsboot: DLC from <path>.Documents/aocis excluded from backups. Givenresources.env,scripts/push_romfs.shtransfers the completeDM_RESOURCE_AOCdirectory with--remove-existing-content true, replacing old<index>.imgfiles and legacy<index>/trees. An empty or omitted value sends an empty directory, clearing previous content and explicitly selecting no external DLC rather than falling back to bundled content. A nonempty path that is unavailable stops before any transfer. A direct RomFS-image push has no DLC metadata and leaves DLC unchanged. Transfers are not atomic: rerun a failed push before launching the game. Usage: Quick reinstalls. - Found on: synthetic startup and transfer fixtures while reviewing PR #486, part of issue #388. The Foundation fixture runs the actual iOS locator; the push-helper fixture models devicectl's documented merge and replacement behavior, including smaller and empty DLC sets and transfer failure. Applies to every game; no device gameplay validation was performed.
A registered build without the profile's DLC stops at the shader split
- Symptom: a game version the profile registers, packed with fewer DLC (or none, or other ones) than the profile was split with, stops at the shader split with
the split shader tables differ from game profile <id>'s, though the NSP script should derive a DLC-only profile for it (the installed DLC shader content differs from the registered tables: using a shader-only derived profile). - Cause:
shader_split.pywrites one row per shader key, where the key was first found, and it scans in path order:aoc/<index>/…sorts before most game paths. A DLC that ships a copy of one of the game's shaders gave that shader a DLC row whenever the DLC was installed, and a game row when it was not.dlc_only_shader_changerequires the game's rows (the rows outside/aoc/) to be the same on both sides, so a profile split with such a DLC built only with that DLC, and one split without it would not have built with it. - Fix: general, in the split (
merge_keys): a key found in both the game and a DLC is the game's row, whatever the scan order; otherwise the first copy is kept, and two different copies of one key are still red. The game's rows are then the same with or without any DLC, and the derivation rule stays strict in both directions. The profiles with DLC rows were split again with their DLC: PRAGMATA's 45 shared shaders moved to the game's rows (no other change); Mario + Rabbids Sparks of Hope (7 DLC) and FINAL FANTASY X/X-2 HD Remaster (2) came out the same; Xenoblade Chronicles 2, split here with more DLC than its profile, derived a DLC-only profile with no game row changed.test_split_dlc_shared(the merge: the game's copy in either order; fails without the change) andtest_nsp_incrementalDlcOnlyShaders(both directions with a shared shader; a profile under the old crediting is refused). - Found on: PRAGMATA v196608 from a NUP with no DLC, against a profile split with
re_dlc_000.pak, which holds 45 of the game's shaders (issue #2439, diagnosed by its reporter and a commenter, both splits checked on their data).
A program of a multi-program game mounts the wrong DLC
- Symptom: a program packed alone (
--program N) or packed with its launcher (the launcher's profile names it inprograms) mounts another DLC than the one it asks for, or none: the build printsDLC index 0:for the application's first DLC, the run reports one index fewer than the build extracted (aoc: reporting 1 add-on contents {1}for two DLC),fs mount dlc:names the wrong image, and the program can end at start (nnMain returned). - Cause: a program's build runs with its own title ID, the application's plus N, and
extract_aocnumbered each DLC from that title ID (index = title ID − title ID of the build − 0x1000). A DLC belongs to the application and the game asks for it by its index from the application, so every image of program N was N below its index: the application's DLC 1 became0.img, which no game asks for, and the game's DLC 1 was the application's DLC 2. - Fix:
extract_aocnumbers from the application's title ID (the build's with its low three hex digits cleared, as a base game's ends in000), and a program's DLC extraction key carries that change, so anaoc/numbered the old way is extracted again.test_a_programs_dlc_are_the_applicationsintest_nsp_scan.pychecks the names. - Found on: METAL GEAR SOLID: Peace Walker - Master Collection Version (
0100C6F01C4F8000, 1.3.1), whose launcher starts the game in program 1 (0100C6F01C4F8001): with the Multilingual Pack (…9001) and the Pre-Order Bonus (…9002), program 1 mounted the Pre-Order Bonus where it asked for the Multilingual Pack and ended at start; numbered from the application, it mounts1.imgwith the pack's 273 entries and gets past its start.
Launcher metadata
A game packed from a NUP or a dump shows "Ver. ?" for a build its profile registers
- Symptom: the game shows
?where it shows its version (Super Mario Bros. Wonder's title screen:Ver. ?), and the build's lines name the version asv327680 (?). - Cause: a package with no control data (a NUP update, a dump) packed from a derived profile, here because the folder had no base game for the shader tables.
derive_profiletook the display version of the build row it writes from the package'scontrol.nacpalone and wrote?without one, and the host answersnn::oe::GetDisplayVersionfrom that row bymain's build ID (hle_sdk16.c). The profile it derives from registered that very build, with its display version. - Fix:
derive_profiletakes the package's control data first, then the display version the profile registers for thismainbuild. The selected package's numeric label can supply the version when those sources have no answer. - Found on: Super Mario Bros. Wonder (1.2.1, v327680, an update-only NUP;
mainff773e90…, the registered build):Ver. ?before,Ver. 1.2.1after, one Mac boot each to the title screen. - Check:
dm/tools/tests/test_nsp_alias.pytest_derived_profile_keeps_the_display_version_the_profile_registers_for_the_build.
An unregistered NUP build loses its numeric version label
- Symptom: the title menu of a game packed from a NUP with a version label shows
version: ?. - Cause: the NUP has no NACP and the profile has no matching build. The packer discarded the NUP label and wrote
?into the derived build row thatnn::oe::GetDisplayVersionreads. - Fix: the survey, derived profile and app read the selected package's version label from the NUP. The label accepts one to three ASCII numeric components, an optional
vand up to 15 version bytes. A label equal to the package'sv<number>tag is ignored. The label stays with its package and is read again on each build. - Found on: Mario Kart World 1.8.0. The reporter rebuilt the game and verified the title menu. Reading the local NUP and deriving its profile also gave
1.8.0for both the build row and bundle metadata. Issue #2902
An app packed without control data says version 1.0
- Symptom: Finder shows
Version 1.0for a Mac app whose game is at another version. - Cause: the app packer got its version from the game's NACP. A dump or NUP can have no NACP, leaving the bundle packer to write its default even when another source identifies the version.
- Fix: Mac apps and IPAs take the packed version's NACP first, then the numeric version from the packed build's profile row, then the base game's NACP, then the selected NUP package's version label. The build can read the base NACP from the NUP even when it only extracts the update. With no usable value the app defaults to
1.0. - Found on: The Legend of Zelda: Ocarina of Time. The author rebuilt the Mac app from a NUP whose selected update was labelled
1.1.1and checked both version fields inInfo.plist. The local NUP has neither a NACP nor a display label. The profile registers1.1.1for its verified v131072 build ID, which gives the local build the same app version. PR #2822 - Check:
dm/tools/tests/test_nsp_nup.pyexercises the app fallback through the packing entry point with a synthetic NUP and the registered Ocarina of Time build IDs.
No Game language row in an app packed from a NUP or a dump
- Symptom: the settings of a Mac app or IPA packed from a NUP or a dump folder have no Game language row, while
DM_LANGin the environment changes the language. Reported on Donkey Kong Bananza (NX2Apple#619, #659; the reporters' packed files were not available). - Cause:
settings.pyshows the row when the game'scontrol.nacplists more than one language, and two cases gave it none. A NUP update may carry no control data: the NSP script's language check fell back to the base game's file, but the Mac settings got only the update's path, andbuild_ipa.sh's fallback ($W/data/v0) is a folder the NSP script does not make. And there may be no NACP at all: the Yoshi and the Mysterious Book and Age of Imprisonment NUPs carry none in any package, and an FTP dump such as Bananza's has no control data. - Fix:
languages_controlinbuild_ipa_from_nsp.pypicks the file once (the packed version's, else the base game's), for the check,mac_appandbuild_ipa.sh(CONTROL). With no list,settings.pyoffers every language with a note, asgame_languageandDM_LANGalready accept any. Age of Imprisonment shows a language it lacks as English (Russian, Portuguese) and has more text languages than its voice folders suggest (Dutch, Simplified Chinese), so a game's list cannot be read from its folders. - Found on: code reading and the NUP records of the two games above, with PR #1182; boots of Age of Imprisonment to its first settings screen. Not confirmed on Bananza by the reporters.
An app packed from a NUP's update has no icon
- Symptom: the Mac app has the system's blank application icon (no
AppIcon.icnsin itsContents/Resources), though the NUP carries the game's icon. - Cause: the NUP has the icon on its base game's record and none on the update's.
pack_versionsaved the packed package's own records only, and the NSP script looks foricon.jpgin the packed version's folder, then in the folder the base game is extracted to alone. A profile that builds from the update only makes no such folder, so the base game's icon was never written. - Fix:
pack_nup.controlgives an update without an icon its base game's (the icon record, else its localized icons, as for its own). The NACP stays the package's own, since its display version and languages are that version's. - Found on: The Legend of Zelda: Ocarina of Time (v131072). The profile builds from the update alone, and its Mac app had no icon because the NUP's 256×256 JPEG was on the base record. The PR #2823 author applied the fix to an older main revision and repacked the Mac app. The update's extraction contained the base game's
icon.jpg, the app containedAppIcon.icnswith the game's artwork, and the signature verified. - Check:
dm/tools/tests/test_nsp_nup.pytest_update_without_an_icon_takes_its_base_games.
A Mac front end's default settings change Metal execution paths
- Symptom: starting a Mac app through a front end with unchanged settings enables the encode thread, and can disable Metal 4 pipelines and the pipeline archive; starting the same app from Finder keeps the host's defaults.
- Cause: Mac
launcher.jsonreused iOS defaults fromsettings.tsv.rec_oninnvn_rec.hdefaults off on Mac and on on iOS;pso4_oninnvn_mtl.mdefaults on on Mac and follows the profile on iOS. The exported defaults instead enabled the encode thread everywhere and followed the profile for Metal 4 everywhere. A front end applying those values changed the Mac host's behavior without a player override. - Fix: a setting's default may be
<ios>|<mac>, selected before resolving a profile macro or build variable. Metal 4 usesDM_GAME_PSO_MTL4|1, the encode thread1|0. The generator validates the platform and the pair. Tests cover a profile with Metal 4 on and one with it off, and both platforms; the host and shader chain are unchanged. - Found on: synthetic metadata generation for Super Mario Bros. Wonder while reviewing PR #352; checked against the native defaults, without a gameplay run.
The Mac settings window stays on screen after Play
- Symptom: in a Mac app, the settings window stays on screen after Play, not responding (a spinning cursor over it), until the game ends.
- Cause: the window runs in the launcher's process (
dm/mac/Launcher.swift).finishordered the window out and stoppedNSApp.run; thenlauncher.cstarted the host and blocked inwaitpid, so the main thread never ran another run-loop pass. A window's order-out is committed only at the end of such a pass, and its default fade-out runs over several passes, so the window never left the screen. With the run loop kept running, the same order-out took effect at once. - Fix:
finishsets the window'sanimationBehaviorto.nonebefore the order-out, anddm_mac_launchercallsCATransaction.flush()afterrun()returns, before it hands back tolauncher.c. Neither alone was enough. Check: a copy of the window with a timed Play and aCGWindowListCopyWindowInfoprobe while the thread then blocks; the window was still listed 2 and 4 s after Play before the fix, and gone 3 times in 3 after it.test_launcher_storage.pyandtest_nsp_mac_app.pypass. - Found on: the Mac app of Breath of the Wild; applies to every Mac app.
External drives
A game folder on an exFAT drive reads one update as two, or fails to remove a folder
- Symptom: with the NSP folder on an exFAT or FAT drive, the build leaves out an update whose name has no
[v…]tag (the folder seems to hold two), or a stage stops withFileNotFoundErroron a._<name>path inside<id>_build/and the next run fails on the half-deleted folder. - Cause: these file systems have no extended attributes, so macOS keeps a file's attributes (a download's quarantine flag) in an AppleDouble file
._<name>beside it, and deletes it with the file.scan_nspstook._Update [<title ID>800].nsp, 4 KB of metadata, for an update: its name carries the title ID. Deletingxtakes._xwith it, soshutil.rmtree's later unlink of the listed._xfound it gone; before Python 3.13 that error ended the removal. - Fix:
scripts/build_ipa_from_nsp.pyscan_nspstakes a file only when its header is one nx_extract opens (is_package:PFS0at 0, or an XCI'sHEADat 0x100), and says which files it skips. The name tag alone no longer counts, so the same check also rejects any other tagged file that is not a package. Names that start with._are skipped without a line. The script'srmtreepasses ENOENT fromshutil.rmtree(the entry is gone, which is the goal) and raises every other error.dm/tools/tests/test_nsp_external_drive.pyandtest_nsp_scan.pycover both without game files. - Found on: the NX2Apple fork's users, who keep games on external drives (PR #476, part of issue #388); reproduced on an exFAT disk image made with
hdiutil create -fs ExFAT. Applies to every game.
The c1 guard stops on an AppleDouble file after the shader build
- Symptom: with the build folder on an exFAT or FAT drive, the shader step compiles every library and then stops in
c1_guard.pywithUnicodeDecodeError: 'utf-8' codec can't decode byte …(dmsh_build.py:[RED] c1_guard.py failed), reading a._<key>_b.metal. - Cause: the same AppleDouble files as above, beside the shader build's outputs.
c1_guard.pytook every name ending in.metalfor a shader's MSL and read the binary._file as text.cb_extent.py(every_b.json) skipped it only because it ignores what it cannot parse, anddmsh_mtlcache.py(every_b.metal) took._<key>_bfor a shader, found no readable reflection for it and so filled the Metal cache from none of that folder's libraries. - Fix: the three take only the names the shader build writes,
<16 hex key>_b….metal/.jsonasdmsh_build.py(OUT_KEY) andregress.pyalready did:c1_guard.pyoutputs(whichcb_extent.pyuses too) anddmsh_mtlcache.pyOUTPUT. None of them is part of the chain version.dm/tools/tests/test_nsp_chain.pyruns both table tools on a folder with._files; the oldc1_guard.pystops on it. On 13 Sentinels' 751 shaders both tables are unchanged. - Found on: a user's iOS shader build on an external drive (PR #555). Applies to every NVN game.
The Mac app step stops on AppleDouble files in its inputs, its copies and its signature
- Symptom: with the build folder or the app on an exFAT or FAT drive, the Mac app step stops in
pack_app.py. The first form it takes isno input file at <build>/shader/cache/<chain>/._<key>_b.metallib, orno rewriter fixups for <build>/<version>/._main.patched.binwhen the modules come first. When the inputs get past it, the copies stop withchflagsorPermission denied, and the signing step stops withcodesign failed (1): code object is not signed at allandIn subcomponent: …/Contents/MacOS/._nxnative, which reads like a broken launcher build. - Cause: the same AppleDouble files as above. The module, shader, pipeline and font globs of
selected_inputstook._<name>for a module or a library, and a._x.patched.binhas nox.fixups.tsvbeside it.shutil.copy2of the host tried to set the copy's flags on a file system without extended attributes (chflags: Operation not permitted), andcp -Rcarried a folder's sidecars into the bundle, whereDMModuleFileslisted them.codesignthen read the._nxnativebeside the launcher as a nested code object that is not signed and refused the whole bundle. Signing also sets an attribute on what it signs, so the sidecar comes back after a successful signature. - Fix:
dm/mac/pack_app.pydetritus()drops those names fromselected_inputs, so neither the pack norDMModuleFilessees them.copy()passes-Xwhere it copies and not where it clones (cprefuses the two together), and the host goes throughshutil.copyinstead ofcopy2, so a copy creates none of them.strip_detritus()runs beforecodesignreads the staged bundle, runs again afterxattr -crwhencodesignstill refuses one, and runs once more after signing. On APFS nothing changes: no sidecar exists there, and the two passes are a stat walk.dm/tools/tests/test_nsp_mac_app.pyputs a._file in every input folder and checks that it is not selected, does not reach the bundle, and is not inDMModuleFiles. - Found on: the NX2Apple fork's users, packing Mac apps on an external drive (LNPANDY/NX2Apple#486); reproduced on an exFAT disk image made with
hdiutil create -fs ExFAT, where the same inputs pack, sign and passcodesign --verify --strictwith the change and stop three ways without it. Applies to every game's Mac app.
A second Mac app build stops with [Errno 45] when it replaces the old app
- Symptom: with the app on a Mac OS Extended, exFAT or FAT drive, the first build into a folder works and the next one that changes anything stops in
pack_app.pyreplace_appwithOSError: [Errno 45] Operation not supported: '<app>'. The old app stays in place. - Cause:
replace_appexchanges the new and the old app withrenamex_np(RENAME_SWAP), which only APFS offers: the others returnENOTSUP. A first build has no old app to exchange, so it takes a plain rename. - Fix: on
ENOTSUPorEOPNOTSUPP,swap_by_movesmakes the state the swap leaves with three renames (the old app to<app>.old, the new one to<app>, the old one to<app>.partial), so the key write and its rollback do not change. A rename that fails undoes the ones before it. These volumes cannot make it atomic: a process killed between the first two renames leaves no app at<app>, with the old one at<app>.olduntil the next replacement clears it. APFS still swaps. Tests:dm/tools/tests/test_nsp_mac_app.pytest_volume_without_atomic_swap_replaces_by_moves,test_fallback_restores_the_old_app_when_a_move_failsandtest_fallback_clears_an_old_app_a_killed_build_left_aside. - Found on: a user's rebuild onto an external Mac OS Extended (Journaled) drive (LNPANDY/NX2Apple#595, PR #1190); reproduced on HFS+ and exFAT disk images made with
hdiutil create, where thePackReusetests stop with the real errno without the change and reach the fallback with it. Applies to every game's Mac app.
External shader directories contain AppleDouble metadata
- Symptom: on an exFAT or FAT drive, shader splitting stops with
ValueError: not a version 2 shader code archiveor[RED] /glslc_capture/._…: no GLSLC output. - Cause:
shader_split.pyselected captured.glslcprograms and decoded.ushaderbytecodearchives by extension alone. macOS AppleDouble sidecars retain that extension, but their._<name>files contain metadata rather than shader bytes. - Fix: exclude
._names when listing both external shader directories, includingDM_GLSLC_CAPTUREandDM_UE_SHADERSoverrides. Other dot-prefixed names remain valid inputs, and malformed real inputs still fail their normal validation. - Found on: an external-drive build reported in issue #229's follow-up. That commenter used a different, unnamed game; this fixes the sidecar failure, not the original Metroid Prime 4 port.
Compressed inputs
NSZ decompression rejects --keys
- Symptom:
decompress NSZstops immediately withnsz: error: unrecognized arguments: --keys …. - Cause:
nsz4.6.1 has no--keysargument. It loadskeys.txtbesidesys.argv[0], or falls back to~/.switch/prod.keys, while importing its modules, before parsing arguments (4.6.1 key loader). Version 5.0 supports--keys(argument parser); stagingkeys.txtalso supports 4.6.1. - Fix:
scripts/build_ipa_from_nsp.pydecompress_nszprefers the current Python's module: it links the file selected by-kaskeys.txtin the conversion's temporary folder and runsnsz -Dthere, withsys.argv[0]set tonszbefore import. Without the module,nsz_commandprobesnszandnsz-cli-macos-arm64on the build's PATH and passes--keysto the first whose successful help lists that option. An unsupported or failed candidate does not hide the next one; when none works, the error lists the reasons and installation options. Executable, input and output paths are absolute because conversion changes directories. The temporary folder and link are removed on success or failure; the user's default keys are untouched. - Found on: Super Mario Odyssey, converting its v0 NSZ. Applies to NSZ and XCZ inputs for every game. Synthetic tests during PR #327 also reproduce an older console script hiding the release binary, a failed help probe containing
--keys, and a relative PATH executable failing after the directory change; no game files are needed for those cases.
ZBIC-compressed NSO segments
- Symptom: the NSP script or any module tool stops on
main:compressed with zstd (NSO flag bit 7), which this loader does not decode yet; with the decoder but without its package,ZBIC (zstd) segments need the zbic package (python3 -m pip install zbic). - Cause: from system 22.0.0, an NSO may store its segments as ZBIC, NSO flag bit 7 for the whole module (the per-segment compression and check-hash bits keep their meaning). ZBIC is Nintendo's variant of zstd, not a container around standard frames: its frames start with the magic
ZBICand its FSE tables are written with binary interpolative coding, so neithercompression.zstdnor thezstdcommand can read them. - Fix:
dm/tools/nso.pydecodes such segments with thezbicpackage (Kinnay's, zstd with Atmosphère's ZBIC changes), imported only for a flag-bit-7 module; every segment is still held to the header's size and SHA-256. zstd has no fixed ratio bound, so a ZBIC segment is held only to its own size, where an LZ4 one is also held to 255 bytes per stored byte. Install it with the other tools (README, step 1). The NSP script checks for it before it extracts anything, as it does for its other modules, because it first reads a module at the rewrite, after the whole RomFS is unpacked. - Check: Well Dweller's
maindecodes to 85,370,056 bytes with segments0x39680d0 / 0x9f7e74 / 0x9b1930, every SHA-256 matching;dm/tools/tests/test_nso.pychecks that a flag-bit-7 module whose segments are not ZBIC is an Error naming ZBIC. - Found on: Well Dweller (SDK 22.2.0).
Versions with different modules
A version without one of the profile's modules stops the host at boot
- Symptom:
FATAL open <folder>/subsdk1.fixups.tsvright after the host starts, orbuild_ipa.shstops withno rewritten module …/subsdk1, for a version that has no such module. - Cause: a game's versions can differ in modules: Mario Kart World's base game has
main,subsdk0(a Mono runtime) andsdk, its update 1.8.0main,subsdk0(the movie player),subsdk1(a C library) andsdk. The host, the rewrite, the IPA and the shader split all took the onemoduleslist of the profile. - Fix:
moduleslists all of them in load order, and eachbuildrow names its own (game.pybuild_modules; a row naming onemoduleslacks is an error). The host loads the modules of the row ofmain's build, read from the rewriter'smain.fixups.tsv(main.cprofile_modules, fromDM_GAME_BUILD_MODULES), and all ofmodulesfor a build with no row.build_ipa.shtakes the same list (game.py modules <id> <folder>). The NSP script rewrites, sizesmem_usedfrom and splits the modules the packed version's ExeFS holds (Game.modules_in), and a derived profile's row names those (derive_profile). - Found on: Mario Kart World: the base game boots with its three modules from a profile that lists four. Applies to every game.
test_game_profile.pychecks the rows and the list.
Package identification
An update is taken for the version in its file name
- Symptom:
[RED] leaving out update NSPs without a version tag ([v<N>]) in their name, for every untagged update when the folder holds any other update (….v720896.UPD.nsp, PR #393). A single untagged update is packed as the newest version the profile registers, whatever it is. A wrongly tagged update is packed as the tagged version, and after the whole extraction the build IDs disagree with the profile's row and the build goes on from a derived profile, without that build's fixes. A base game served at a later version is packed asv0, which the profile may not register: Castlevania: Belmont's Curse's base is 1.1.0 (v65536) and its profile registers onlyv65536. - Cause:
scan_nspstook each package's version from the[v<N>]tag in its file name and its title ID from its ticket or tag; it read a package's content metas only when it held several. A base game was alwaysv0. Tags drift in real collections: a Castlevania base NSZ was tagged[v0], while its content meta andcnmt.xmlsay v65536. - Fix:
scan_nspsreads every package's content metas in one run,nx_extract <prod.keys> --contents <package>...(package <index> <file name>, then onecontent <type> <title ID> <version>line per content meta; only headers and the meta NCAs are read, about 0.05 s for a folder). Each package's title ID and version are its content metas', for the base game, every update and every DLC, so a file's name no longer matters to the build.nsp_versionsnames the base game by its own version (v0for most games;v65536for that Castlevania base, its profile's registered row). A[v<N>]tag that disagrees is said in one line and ignored. Keys that cannot open the meta NCAs stop the scan withnx_extract's line (Keys older than the game). A package that cannot be read, or that holds no base game, update or DLC (a delta update), is skipped with a[RED]line, since it could not be extracted either. The ticket and tag readers (title_of,nx_extract --title,is_merged) and the untagged-update guess are gone. DLC extraction always names the DLC's title ID (--aoc … <DLC title ID>). - Found on: Castlevania: Belmont's Curse's base game (issue #1629). Checked with the real tool on renamed links: Balatro with an untagged update (base v0, update v851968); Mario Kart 8 Deluxe with its update tagged
[v65536](taken as v1441792, said), an untagged DLC (v65536) and a truncated package (skipped:ResultFsOutOfRange); NieR:Automata's XCI; keys holding onlyheader_keystop withprod.keys has no key_area_key_application_0c. Applies to every game.
An NSP without a ticket or a title ID in its name stops with "no NSP with a readable title ID"
- Symptom:
[RED] no NSP with a readable title ID in <folder>, although the keys open the package (the launcher's key check passes). Renaming the file toGame [0100XXXXXXXXXXXX].nspmakes the build go on. - Cause:
title_oftook the title ID only from the ticket's file name (<rights ID>.tik) or from a[title ID]tag in the package's file name. Many NSPs carry no ticket (standard-crypto dumps, repacks), and a download's file name often has no tag. - Fix: with neither,
title_ofasked the package (nx_extract <prod.keys> --title <package>: the lowest title ID of its meta NCAs' headers). Since issue #1629 every package's title ID comes from its content metas, ticket or not, tag or not (An update is taken for the version in its file name);title_ofand--titleare gone. It works for NSP, NSZ (the meta NCAs are not compressed), XCI and XCZ.nx_extractis built into a temporary folder for it, since the build folder is named after the title ID. Key values are never printed. - Found on: NX2Apple, LNPANDY/NX2Apple#177 (Tears of the Kingdom, whose base NSP has no ticket). Applies to every game.
A game file whose extension is in capitals is not found
- Symptom:
[RED] no NSP with a readable title ID in <folder>for a folder holdingGame [0100XXXXXXXXXXXX].NSP, on any Mac volume; renaming it to.nspmakes the build go on. A dump folder besideGame.NSPis packed instead of the package, andGame.NUPis not found. AGame.NSZstops withnsz made no Game.nsp. - Cause: the script listed the folder with
Path.glob('*.nsp'), which compares case-sensitively on every POSIX system, a case-insensitive Mac volume included. nsz has the same limit of its own:PathTools.isCompressedGametakes only a lowercase extension, and nsz skips anything else and exits 0 with no output. It resolves a symlink before it looks. - Fix:
files_with_suffixlists a folder's files by their lowercased extension, for every scan of the inputs, and a package beside a compressed one is found in that listing. A compressed file in capitals goes to nsz as a hard link with a lowercase extension in its temporary folder, or as a copy where there can be none (another volume, exFAT), so the player's file stays as it is. - Found on: NX2Apple, LNPANDY/NX2Apple#554 (Tears of the Kingdom). Applies to every game.
A merged NSP (base game, update and DLC in one file) packs as one title
- Symptom: a game folder holding one merged package (
[Base + Update + DLC].nsp, or a 1G+1U cartridge dump with no update NSP beside it) stops withno base game NSP found, or packs the base game alone (v0) without its update and DLC; when the base game's own build cannot be packed (Mario Kart 8 Deluxe 1.0.0'smainis 32-bit), the build stops there. - Cause:
scan_nspsgave each file one title ID: its first ticket's, else its name's tag. A merged package holds a ticket per title in any order, so it counted as the base game or as the update, never as both, and its DLC was never seen.nx_extractthen read the update from a separate update NSP only. - Fix: a package is asked for its content metas (
nx_extract <prod.keys> --contents; first only a package whose file table held more than one*.cnmt.nca, since issue #1629 every package: An update is taken for the version in its file name), and counts as each Application, Patch and AddOnContent it lists, with the versions from the metas. The one file is then given tonx_extractas both the base game and the update:OpenNspkeeps the NCAs that the Application content meta lists for the base and the Patch content meta's for the update, both of the application being packed (--app), and--aoc <package> <out> <DLC title ID>takes one DLC's data NCA by its title ID. The extraction estimate, the progress total and the NSZ conversion count the file once. A DLC NSP that bundles several DLC is read the same way. - Found on: Mario Kart 8 Deluxe (0100152000022000, no profile here) from one merged NSP, in NX2Apple (PR #842, LNPANDY/NX2Apple#376). Checked with Balatro's update NSP and base NSP merged into one PFS0: it scans as base v0 and update v851968, and
nx_extractgiven it as base and update writes the same ExeFS, control data and RomFS manifest as the two separate NSPs. Applies to every game.
A derived profile leaves out a module that moved to another slot
- Symptom: a version a profile was not brought up on crashes at its first movie:
UNIMPL _ZN5movie9ExtractorC1ENS_13ContainerTypeE, thenCRASH sig=11(issue #1211). The derived profile'smoduleshas onlymain sdk. - Cause:
derive_profilecould only take modules out of the profile's list, but a module's slot belongs to a build, not to a game: Absolum's movie module issubsdk2in 1.1.2, wheresubsdk0is NVIDIA's Vulkan driver, andsubsdk0in 1.2.1. - Fix:
derive_profileadds whatprofile_guess.main_modulesfinds: a module the list leaves out that exports somethingmainimports, which no listed module and no host hook supplies, and never a GPU driver. It shares this withnro_modules(modules_supplying). The added module goes in the version'sbuildrow too, since the host loads what the row names. Checked on 9 games' real modules with their registered lists: nothing is added (Super Mario Galaxy 2's GLSLC andnn::pcm, which the host supplies, stay out), and each of the 7 subsdks taken out of a list comes back. A registered build keeps its row: the rule runs only when a profile is derived. - Found on: Absolum 1.2.1, from the reporter's logs: with the module added by hand the game reached gameplay at 60 fps. No 1.2.1 files on this Mac: not run here.
A derived profile loads only the modules its version ships
- Symptom: the NSP script stops at its rewrite stage with
FileNotFoundError: … extract/v0/ExeFS/subsdk1while packing a version the profile was not brought up on; the extraction has every other module. - Cause:
derive_profileinscripts/build_ipa_from_nsp.pygives the derived profile this version'sbuildrow, made only from the modules its ExeFS holds, but copiedmodulesunchanged. A version that ships fewer modules than the registered one (an older base game before an update added a module) then names a module the rewrite and the host try to load. - Fix:
derive_profilekeeps inmodulesonly those the version's ExeFS holds, with a comment naming the ones left out; a version that ships them all keeps the line as it is, andshader_onlyderivations are unchanged. The host is built from the derived profile, so it loads the same list. - Found on: Mario Kart World 1.0.0 (
0400C3F00006E000, a base-game dump:main,subsdk0andsdk), packed from a profile for 1.8.0, whosesubsdk1is the C library module the update added (PR #1081). With it the rewrite, the shader split (11,561 shaders) and the Mac host built, and the game drew its first course on the Mac. - Check:
test_nsp_incremental(test_a_module_the_version_does_not_ship_is_left_out: the module left out with its comment and its build row, then kept once the version ships it).
Another edition's files lack the profile's RomFS marker
- Symptom: a game packed under another title ID than its profile's (another region's edition of the same
mainbuild) builds its shaders, then stops at the app step withno RomFS at …/RomFS.img (missing CPK/ALL_USEU.CPK)(on iOS also[RED] missing RomFS marker). Every build of it extracts the whole package again, though nothing changed. - Cause:
romfs_markernames a file of the edition the profile was brought up on, and another edition may name its files differently: Persona 5 Royal's Asian title hasCPK/ALL_ASIA.CPKwhere the registered one hasCPK/ALL_USEU.CPK.derive_profilecopied the marker unchanged, so the app step checked the RomFS for a file it never holds.extractalso took the image for reuse only when it held the marker, read from the registered profile before any derivation, so it never reused this edition's image. - Fix: general, in
scripts/build_ipa_from_nsp.py.derive_profile, for a profile derived under another title ID, keeps a marker the version's RomFS holds and otherwise takes the largest file it holds, as a provisional profile does; the choice is in the derived key. A profile derived under its own title keeps a missing marker, so the app step still stops on a damaged or mixed-up RomFS, as does an empty one.extractreuses an image by its extraction key and a valid index (romfsreads it as a directory), not by the marker: the key names the packages, the options and thenx_extractthat made it, andswap_innever leaves a half-replaced image in place (Stopping a build while it replaced an output). - Found on: Persona 5 Royal's Asian title
01004B10157F2000v65536 (PR #1882): on the reporter's RomFS the rule takesCPK/ALL_ASIA.CPK, and the Mac app packed and passed its codesign check with that marker. Its gameplay and iOS are not tested. The extraction reuse is inferred from the code and checked by the tests, not timed on the game. - Check:
test_nsp_incremental(test_cross_title_marker_uses_actual_regional_resources: folder and image, with and without the inherited marker, then reuse; the same title, an empty RomFS and a shader-only derivation keep the marker) andtest_nsp_extraction_keyProgram(an image without the registered profile's files is reused under its key; one with a cut index is extracted again).
Keys
Keys older than the game stop the extraction with an unhandled MissingKeyException
- Symptom:
nx_extractstops with exit code 134 andUnhandled exception. LibHac.Common.Keys.MissingKeyException: Unable to decrypt NCA section.withKey Name: key_area_key_application_<NN>(ortitlekek_<NN>), after any NSZ conversion, the build ID lookup or the survey. An NSZ converted with such keys is written anyway:nsz -Dwarnsmaster_key_<NN> missing … This will lead to corrupted output.and exits 0. - Cause: each NCA's header names the key generation its content needs; a prod.keys dumped from a console on older firmware than the game lacks that master key and every key derived from it. Nothing checked the keys against the packages before the first step that decrypts them, and LibHac's exception reached the log as a crash.
- Fix:
nx_extract <prod.keys> --keys <package>...opens every NCA of the packages (an NSZ's or XCZ's compressed ones by their header, which nsz keeps as it was) and applies LibHac's own test (CanOpenSection). On the newest key missing it prints[RED] <file>: prod.keys has no <key> (master key <NN>, which came with firmware <version>) …and exits with code 6; a rights-ID NCA with no common ticket is named the same way. The NSP script runs it once after scanning the folder (check_keysinpackage_reader), beforensz -D, the survey and the extraction, and stops with that line; any other failure of the check is left to those steps. Extraction,--aocand--contentsrun the same check before they decrypt anything (the content metas first), sonx_extractalone also stops with exit code 6 instead of a crash. The firmware table runs to 21.0.0 (master key 0x14); a newer key is named as "a firmware after 21.0.0". The check reads only headers: the NSP script stops on Balatro's two NSPs in about 1.5 s. - Found on: NX Library (Bium23/NxLibrary), a Mac front end that checks the keys before starting a build, an idea from NX2Apple. Checked with Balatro's NSPs and an NSZ of its base game, with a copy of prod.keys without the keys of master key 0x10 and later (and one without 0x0a and later): every path names
key_area_key_application_10and firmware 17.0.0, and the complete keys pass and extract as before. Applies to every game.
Cartridge dumps
A cartridge dump with its update on it extracts the update as the base game
- Symptom: the extraction of a game whose base is an XCI that also carries its update (a "1G+1U" dump) stops with
[RED] nx_extract exit code -6.extract_v<version>.loglists the update's build IDs even for the base game alone, then ends in an unhandled exception from the RomFS (ResultFsNonRealDataVerificationFailed (2002-4604): Hash error!fromRomFsFileSystem..ctor, orArgumentException/InvalidOperationExceptionfrom the patch layers). - Cause: the XCI's secure partition holds the update's NCAs beside the base game's, and the update's Program NCA has the program's title ID too.
nx_extracttook the first Program NCA of the lowest title ID as the base, which is the update's when the dump lists it first. Its data section is a patch (BKTR) over the base RomFS, so it cannot be read alone or under another patch. The ExeFS still opens, with the update's build IDs, because an update's code section is complete. The Control NCA (display version, icon) was also whichever of the two came last. - Fix:
dm/tools/nx_extract/Program.csOpenNspreads the base package's content metas (*.cnmtin its Meta NCAs) and keeps only the NCAs that its Application content meta lists, and prints how many it left out. When none of them is a Program NCA (NCA files renamed, so their names are not content IDs), it prints a[RED]line and reads every NCA as before. An NSP or a base-only XCI keeps every NCA but its meta NCA, so it extracts as before (Balatro's NSPs and Monster Hunter Rise's XCI give identical manifests). The update on the cartridge is packed too since a merged package counts as each title it holds. - Found on: The Legend of Zelda: Tears of the Kingdom, a 1G+1U XCI (base v0 with update 1.4.3, whose 524 MB Program NCA is listed before the base's 17.1 GB one) beside the 1.4.3 update NSP (PR #311). Reproduced with a package of Balatro's update NSP followed by its base NSP: the base alone and the base with the update now give the same manifests and control data as the separate NSPs. Applies to any game's XCI that carries its update.
A cartridge dump that holds two games packs only the first
- Symptom: an XCI with two applications (Super Mario Galaxy + Super Mario Galaxy 2 on one cartridge dump) always packs the first game;
build_ipa_from_nsp.pynever reaches the second. - Cause: the scan took one title ID per file (the file name tags both games, and the first tag won), and
nx_extractkept the NCAs of every Application content meta and took the Program NCA of the lowest title ID. Nothing could name the other application. - Fix: the XCI's content metas make it count as each title it holds, so the scan finds two games and stops with
more than one game in the folder, naming both.--title-id <title ID>(TITLE_IDin Spyder) picks the game to pack from them; the script passes its title ID to every base extraction (nx_extract … --app <title ID>), andOpenNspkeeps only that title's Application and Patch content metas' NCAs (an--appthe package has no content meta of stops with the ones it has). Each game gets its own<title ID>_build/folder and app. - Found on: Super Mario Galaxy 2, on the same XCI as Super Mario Galaxy (PR #701, which packed both from the XCI with an earlier form of the option). This form is checked with a test XCI's file table and with Balatro's packages (
--appof a title the package does not hold stops, naming the one it has); no two-game XCI is on hand.
Damaged packages
Extraction of a damaged NSP ends in "The LinkedList is empty"
- Symptom:
nx_extractstops with exit code 134 andUnhandled exception. System.InvalidOperationException: The LinkedList is empty.fromLibHac.Tools.FsSystem.CachedStorage.GetBlock, with no[RED] hash check failedlist, with or without--allow-damaged. - Cause: a damaged NSP with more than a few damaged files used up LibHac 0.19's hash cache.
CachedStorage.GetBlocktakes a block off its list before reading into it and does not put it back when the read fails, so the 4 blocks of a filesystem last for 4 failed reads and the next read that misses the cache throws. That exception is no hash error, sonx_extractdid not catch it. A copy of SteamWorld Dig with 2 flipped bytes listed its 2 files; with 40 it crashed. - Fix: each hash error gets a new checked filesystem (
Failedindm/tools/nx_extract/Program.cs, on the image, folder and manifest paths), so a damaged NSP lists every damaged file and stops with exit code 3, or goes on with--allow-damaged. The same copy with 40 flipped bytes lists all 36 files.test_every_damaged_file_is_listed_past_the_hash_cacheindm/tools/tests/test_romfs_read.pyputs a real RomFS behind a realCachedStorageon all three paths, with no NSP or keys. - Found on: Breath of the Wild (issue #810, whose reporter diagnosed the lost cache blocks and carried a local patch that reopens the filesystem). Applies to any game.
A damaged RomFS's own tables
- Symptom:
[RED] the NSP is damaged: a filesystem's own tables fail the NCA's hash check, exit code 3, right after the build IDs; before 2026-11-04,[RED] nx_extract exit code -6with an unhandledResultFsNonRealDataVerificationFailed (2002-4604)underRomfsHeader. The ExeFS reads, and the build IDs and name are printed, since only the RomFS is hit. - Cause: the damage lies in what the RomFS opens from (its header, or the hash levels above it), so no file can be listed, and
--allow-damagedhas no file to write as read. Hashing each NCA tells which one it is: its file name is the first 16 bytes of its SHA-256. - Fix:
nx_extractsays so and exits with 3, as for damaged files. A good copy of the NSP is the only cure. A base game that is intact packs alone with--package <its version>, once it has a profile. - Found on: Mario & Luigi: Brothership: update 1.0.1's Program NCA
074db5a4…(its NSP is also a repack: it holds a.cnmt.xml).
A crash from a damaged NSP's file looks like a host bug
- Symptom: a build packed with
--allow-damagedcrashes or draws wrongly in game code, the same way on each run, at a place unrelated to the host's last work. The log gave no sign of damage; the build log's list (logs/extract_<version>.log) is the only record, and it is not part of a bug report's run log. - Cause:
--allow-damagedwrites files that failed the NCA's hash check as they were read, and nothing told the running host. A wrong byte in a compressed pack decodes to wrong data far from where the game then fails. A hash block also spans neighbouring small files, so a listed file's bytes may still be right. - Fix: the entry's last byte in a
DMROMFS1index (format) is 1 on a file that failed the check (img_ent.flags,romfs_image.h;nx_extractsets it, and every reader refuses another value, or a flag on a directory). The mark stays with the image in an IPA, a Mac app or a hand-copiedromfs.img. The host logs[RED] fs RomFS image <path>: damaged files <N>: ...at the mount and[RED] fs rom:/<file> failed the NCA's hash check ...at each damaged file's first open. A clean image is byte-identical to one from before this mark (checked on SteamWorld Dig), so its identity does not change. Not marked: an image extracted before this change, and folder extraction, which has no index (the NSP script writes images). Search a crash's log forhash checkbefore looking for a cause in the host. - Found on: Breath of the Wild (issue #810).
dm/host/tests/t_fs.cchecks the count, the single report at first open and the refused flags; a boot of SteamWorld Dig on a deliberately damaged image logged the count and the files it opened.
A build that allows damaged files splits and restores every shader again
- Symptom: every build with
--allow-damagedruns the shader split and restores every shader from the compile cache, though nothing changed: about 56 s of split and 9½ minutes of shaders (42,848, about 75 a second) for Ocarina of Time on an M3 Max, each build. - Cause:
split_shadersgave a damaged copy no key (key = None if ALLOW_DAMAGED): a good copy that replaces a damaged one keeps every file's path and size, all that the RomFS input (('tree', …)) sees, so that key would have kept the damaged split. The shader step takes the package's key as its input, so it never reused its libraries either; the Vulkan and OpenGL shader steps were told not to reuse (reuse=not ALLOW_DAMAGED). - Fix: a damaged copy is keyed as the same extraction: its RomFS by its files' times (
('stat', …), which an extraction writes again; insideRomFS.img, the image's) and bycheck_formats' list of damaged files (RomFS.img.formats). A build of the same extraction reuses the split and the shaders; a new extraction (a repaired copy, other options:extraction_key) or another damage list splits again. The Vulkan and OpenGL steps key a damaged copy by times as well (theirprovisionalkeying). An undamaged build's key is as before, and damaged and undamaged builds never take each other's split. - Found on: Ocarina of Time, v131072 built with
--allow-damaged, which a contributor kept on after replacing a NUP with three damaged textures (A damaged file in a NUP or a dump has no hash to fail): the option alone, with no file damaged, took this path.dm/tools/tests/test_nsp_incremental.py(SplitShaders.test_damaged_reuses_only_the_same_extraction).
An update's offline HTML pages reported as a damaged NSP
- Symptom: the NSP script stops at the offline HTML pages (
logs/extract_html_<version>.log) with[RED] the NSP is damaged: <n> files fail the NCA's hash checkand a list under/html-document/, although the program extracted cleanly and the NSZ tool verified every NCA of the update. - Cause: an update's HtmlDocument NCA can be a patch of the base game's.
nx_extract --htmlguessed: it read the update's NCA alone first and over each base NCA second, keeping the first read that did not throw. A read that fails the hash check does not throw, though:Copylists each file as damaged and goes on. So the read alone was kept, the patched one was never tried, and the files it listed stopped the build. - Fix:
nx_extract --html(dm/tools/nx_extract/Program.cs) reads the NCA's header: a data section with a relocation table (IsPatchSection) is a patch, read over the base game's Manual NCAs, and any other is read alone, once, so damage in it is reported as damage. The header does not say which base NCA a patch is over (HtmlDocument and LegalInformation are both Manual), soTryreads over each in turn and undoes a read that adds files that fail the hash check (it deletes the folder and takes the entries off the list). A patch that reads over none is reported with[RED] an HtmlDocument NCA of the update patches none of the base game's, and the log names each patched read (html<n>: a patch of the base game's NCA). - Found on: Super Smash Bros. Ultimate update 13.0.5 (
v2031616) (PR #1215): 1,641 of the NCA's files failed alone; read through the base, 2,798 files (122.2 MB) and none damaged, and the game packed and played a battle on the Mac at 60 fps. Balatro's update has a full Manual NCA: it is read alone, as before.IsPatchSectionchecked on Balatro's update: true on the Program NCA's RomFS, false on its ExeFS, its Manual NCA and every base section.
Extractions kept from an older nx_extract or another copy of the game
- Symptom: an offline page of the game shows white and takes no button:
[RED] web: the page asked for dmweb://doc/contents.htdocs/howto/img/bg_melee.webp, which its document does not have(five such lines: two images, two scripts, a font), thenweb: page error: ReferenceError: Can't find variable: controller_setting. Super Smash Bros. Ultimate opens its How to Play page before the first battle, so the game could not be played past it. The same cause kept a version's program: an image packed with--allow-damagedstayed in a later build without the option, or after a good copy of the same file replaced the damaged one. - Cause: both outputs of
nx_extractfor a version were reused for as long as they existed:extract_htmltookextract/<version>/htmlwhen the folder was there, andextracttookExeFS/andRomFS.imgwhen they were there with the profile's RomFS marker. The app was built with an nx_extract from before the patch read and with damaged files allowed: 1,641 of the 2,798 files of the update's pages failed the hash check and were left out. A later build with the fixed nx_extract over the same build folder kept that folder, so the fix never reached the pages. Neither stage looked at what made its output: which nx_extract, which package files, which options. - Fix: one key for every output of nx_extract (
extraction_keyinscripts/build_ipa_from_nsp.py): nx_extract's source sha (the onefind_nx_extractchecks the executable carries), each package's name, size and time (a good copy has the same name and size), and the options (extract_flags: the application, the program,--allow-damaged). It is written beside the output after the output is in place (extract/<version>/extract.key,html.key,aoc.key), and the output is reused only while it matches; a folder with no key, from a build before it, is extracted again once. A new program extraction replaces the version's folder whole, so its pages are read again with it. A NUP or a dump folder's packer removesextract.key, since what it writes is not nx_extract's. Cost: each change to nx_extract's source extracts every version again on the next build (minutes for a large game; the shader split of a profiled game keys on the RomFS's names and sizes, so its shaders are kept), the pages 4.5 s for Smash.pack_app.pyalready takes the pages as an input of the app, so a Mac app follows. - Found on: Super Smash Bros. Ultimate 13.0.5 (
v2031616), a Mac app built at7249ee9f(PR #1545): itshtml0held 1,157 of 2,798 files. Read again with the current nx_extract: 2,798 files, none damaged, the 1,157 the app had byte-identical. With the 1,641 added to the app, the page loads with no red line, takes buttons and ends (web: the page ended: exit reason 3), and the game goes on to its stage selection. - Check:
dm/tools/tests/test_nsp_extraction_key.py.
Build ID lookup
An unreadable unused base stops discovery after a readable update
- Symptom: for a title ID with no profile, the newest update extracts successfully during
build ID lookup, but the subsequent base-only probe fails its ExeFS hash check and stops the survey, even though the update supplies the code. - Cause:
same_buildtries the newest update's main build ID, then the base game's as a second guess. Both used the same fatal extraction call, making the optional base-only probe a required input. This lookup error is independent of why that base cannot be read; the reported base hash failure has not been diagnosed as damage or a sparse NCA. - Fix:
scripts/build_ipa_from_nsp.pysame_buildcatchesBuildErroronly on the base-only probe after the newest update's extraction succeeded. It logs[RED] the base game alone could not be read for the build ID lookup; the update supplies the code, so the survey goes on, deletes the partial output and continues without an alias match. A failed update extraction, a failed base-only extraction when there is no update, and other exceptions still propagate. The extractor requires a matching update Program NCA and reads its complete ExeFS with integrity checks; its accepted sparse-base exit code 4 cannot occur with an update Program NCA. The survey and build's actual extractions remain strict. This is a general lookup rule, separate from recognizing a sparse base; it does not disable integrity checks or repair the unreadable base. - Found on: Pokémon Violet (PR #2701).
- Check:
dm/tools/tests/test_nsp_alias.pycovers continuation after an unreadable optional base and preservation of the required base-only failure.
Sparse base games
The survey's build ID lookup stops on the base game alone with a hash error
- Symptom: for a game with no profile, the NSP script stops at
build ID lookup · main of the base gamewith[RED] nx_extract exit code -6;<title ID>_survey/logs/exefs.logends inResultFsNonRealDataVerificationFailed (2002-4604): Hash error!fromPartitionFileSystemMetaCore.QueryMetaDataSizeunderNca.OpenFileSystem, although every NCA in both NSPs matches its content ID (the SHA-256 that names it) and the base game with its update extracts cleanly. - Cause: the base game's Program NCA is sparse: its code and data sections carry a sparse layer and leave out data that the update supplies, so the base is smaller than its update (1.6 GB against 2.9 GB). Horizon mounts such an NCA only through its patch; read alone, the left-out ranges fail the hash check from the first block of the ExeFS. The lookup (
same_build) tries main's build ID of the newest update first, then of the base game alone, andrunstopped the build on the second attempt's failure. - Fix:
dm/tools/nx_extract/Program.csstops with exit code 4 and[RED] the base game's program is sparse: it can be read only with its update NSPwhen it is given a sparse base without an update (any enabled section of the Program NCA with a sparse layer).scripts/build_ipa_from_nsp.pyruntakes the exit codes a caller accepts (ok), andsame_buildaccepts 4: the base game alone then has no main of its own and the lookup goes on. The base game with its update reads as before (LibHac layers the update over the sparse base; the whole 4.2 GB merged RomFS of the game below reads with every hash check on). - Found on: Minecraft Dungeons II, base v0 (SDK 22.2.0) with update v131072 (1.1.3.0). Applies to any game whose base Program NCA is sparse.
The offline pages of a sparse base game stop the build as a damaged NSP
- Symptom: the NSP script stops right after
extract v<version>with[RED] the NSP is damaged: a filesystem's own tables fail the NCA's hash checkandnx_extract exit code 3fromlogs/extract_html_<version>.log, although every NCA's SHA-256 matches its name. - Cause: the base game's HtmlDocument NCA can be sparse too (16 KB, beside the sparse Program NCA).
--htmlreads the update's HtmlDocument NCAs, each over a base one when it is a patch, and then every base HtmlDocument NCA on its own; a sparse one read alone fails the hash check while its tables open. - Fix:
dm/tools/nx_extract/Program.csreads no sparse base HtmlDocument NCA on its own (a sparse HtmlDocument NCA of the base game (… bytes): read only through the update's patch, not alone), as Horizon mounts it only through its patch. - Found on: Minecraft Dungeons II, base v0 with update v131072: the update's patch (
accessible-urls) and its full legal information NCA are read, the base's legal information NCA too.
Unreal 4.27 shaders with 8-byte hashes, an untagged record or a version 12 pak
- Symptom: the shader split for an Unreal 4.27 game finds no shaders or stops on the shader library:
shader library chunk … does not parse,pak version 12, only … are read, ornot an LSLG record. - Cause: Godzilla: Destroy All Monsters Melee Remastered uses 8-byte xxHash64 values in its IoStore shader library. The reader supported 20-byte SHA-1 values, as used by FINAL FANTASY RESONANCE. Godzilla's Switch shader records omit the
LSLGand stage tag, and its pak footer is version 12. - Fix:
uepak.pytries 20-byte hashes first and switches to 8 only if the tables fail to parse with matching counts and consume the whole chunk. The version 2 archive stores each 8-byte hash with 12 zero bytes appended. Version 12 follows version 11's footer rules. For untagged Switch records,raw_recordlooks for a unique control section with matching code lengths and a0x880-byte control length.shader_split.ue_shaderstakes the stage from the archive's frequency for those records. - Check:
test_uepak_iostore.pycovers both hash widths, a wrong-width parse that reaches the chunk's end, valid and legacy-position version 12 footers, and untagged records with code or control length mismatches or a copy of the control magic inside shader code. The PR author built 6,878 Mac shaders for update 131072. - Found on: Godzilla: Destroy All Monsters Melee Remastered (
0100A00026D70000).