Skip to content

NSP script --romfs separate: game files stay on the phone between builds, and the app refuses a wrong image - #493

Closed
v0lumehi wants to merge 2 commits into
seedds:mainfrom
v0lumehi:romfs-separate
Closed

v0lumehi wants to merge 2 commits into
seedds:mainfrom
v0lumehi:romfs-separate

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

What and why

Stacked on #478 (DM_COPY_ROMFS=NO for the unsigned IPA). The first commit here is #478's; review only the last one, c60f69d6.

Roadmap #313, "Game files stay on the device". A cold Breath of the Wild build on an M2 Max took 53 min. Of that, packing the IPA took 10.9 min (14.7 GB, nearly all of it RomFS). Every rebuild pays that pack, and then the transfer to the phone, even though the RomFS only changes with the game's version. The parts for keeping it on the phone exist (push_romfs.sh, main.m reading Documents/romfs.img, #478), but as a manual "Quick reinstalls" recipe without a guard against a wrong image. This makes it a route the NSP script supports:

  • --romfs separate (or ROMFS = 'separate' in the settings block): the IPA or Xcode project is built without the RomFS. The image stays where the extraction keeps it (<id>_build/extract/<version>/RomFS.img, reused with the extraction), and the script prints the push_romfs.sh command, needed once per game and version. The default, bundle, is unchanged. --romfs separate with --platform mac / mac-app is an error.
  • A RomFS identity, so a wrong image is refused instead of crashing later. A slim build carries romfs.id in the app bundle, one ASCII line:
    DMROMFSID1 title=<title ID> version=<display version> build=<package version> size=<bytes> index=<16 hex>
    • index is FNV-1a 64 over the image's 32-byte header and its index tables. The file data isn't read, so the check is cheap at every start.
    • Only size and index decide a match; title, version and build are for the message.
    • The app derives the same identity from Documents/romfs.img at start, so no second file on the phone can go stale. The computation is shared C (dm/host/romfs_identity.h) and Python (romfs_image.py --identity).
  • At start (main.m, romfs_identity_accepts, called from one line in romfs_locate):
    • Match: the image is used as before.
    • Mismatch, or a missing or cut-off image in a slim build: a [RED] boot: line and an alert (with the existing game-files label) that names the expected and the found image and the command that fixes it. A valid Documents/romfs folder is still used as before.
    • A build without romfs.id (every bundle build) accepts any complete image, as today.
  • push_romfs.sh also takes a RomFS.img path directly and prints the image's identity before copying.
  • Add-on content stays in the IPA here. Moving it to Documents/aoc for slim builds is iOS: find a game's DLC (aoc/) in Documents before the app bundle #486 and its follow-up; the hunks in main.m and push_romfs.sh are kept apart from it.

Question for @seedds: should separate become the default for iPhone builds once it has been used for a while? I left the default as it is.

Checked

  • Tests:
    • New: test_romfs_identity (the C and Python identities agree; parsing; a mismatch is detected) and test_nsp_romfs (the option, the printed command, the platform error).
    • Extended: test_ipa_unsigned (a slim IPA without RomFS and with romfs.id), test_romfs_startup (match, mismatch, missing, folder fallback, no-identity build) and test_xcode_workflow (the copy phase writes or removes romfs.id).
    • All of dm/tools/tests (421) and dm/ios/tests (36), test_docs and test_env_switches pass. The lint ratchet shows 0 new findings.
    • The iOS compile check (compile_check.py, as in CI) compiles 178 files, 0 failed.
  • Not checked:
    • An install on a device, and the alert on screen.
    • The prepared Xcode project's Gen/dm.xcconfig line.
    • The pack time of a slim IPA. That will be measured on the BotW build and added here.
  • Games run: none, as only the start-up file lookup changes and it's covered by test_romfs_startup.
  • Devices and OS: M2 Max, macOS 27.2.
  • Regress: not applicable. Nothing in the host's game path, the chain or the tools changes.

Docs

  • Not applicable: no finding. docs/development.md (Quick reinstalls), README.md (packing) and docs/env_switches.tsv describe the option
  • Not applicable: no chain tool changed
  • No game files, keys or data extracted from a game in the change or the attachments

…the executable carries the entitlements

The Xcode build phase already takes DM_COPY_ROMFS=NO (the app then reads Documents/romfs.img, scripts/push_romfs.sh); the unsigned IPA now takes it too, so a large game's package stays within what iOS extracts. The default is unchanged.

An unsigned build has no signature for a sideloader to read entitlements from, so the Increased Memory Limit request was lost. The executable now gets an ad-hoc signature with the entitlements (DM_ENTITLEMENTS as for the Xcode project).
…p checks the image

--romfs bundle|separate (ROMFS in the settings block; bundle stays the default) builds the
unsigned IPA and the prepared Xcode project with DM_COPY_ROMFS=NO and prints the one
push_romfs.sh command per game and version. The RomFS image stays where the extraction put
it, so a rebuild neither packs nor sends it again.

A slim build carries romfs.id (title, version, build, image size and a hash of the image's
header and index, cheap even for 14 GB). main.m uses Documents/romfs.img only when its
identity matches, and otherwise logs a [RED] line and shows an alert naming the expected
and found image and the push_romfs.sh command. push_romfs.sh also takes the image directly.
seedds added a commit that referenced this pull request Oct 28, 2026
Add --romfs separate to unsigned IPA and prepared Xcode builds. Keep the extracted image available for one-time transfer and compare its size and header/index identity before using Documents/romfs.img. Keep bundle as the default and keep add-on content bundled.

Reject separate deployment with extraction cleanup before building, since cleanup otherwise deletes the image the printed push command needs. Reject mismatching images while retaining the existing validated folder fallback; regression tests reproduce both original failures.

Validate 451 tool tests (8 optional skips), 38 iOS tests, the actual prepared-project settings in both modes, 178 iOS compilation units, and the lint ratchet. Game regression and build results are recorded in the PR reply. Device startup and sideloader entitlement preservation are not claimed.

Co-authored-by: v0lumehi <[email protected]>
@seedds

seedds commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Taken into main after #478 as 9ac535bb4de0. Thanks @v0lumehi — the separate deployment route, shared C/Python image identity, direct image push support and startup diagnostics are retained, with Co-authored-by credit.

Two general fixes accompany the integration:

  • Reject --romfs separate --no-keep-extracted before building. Otherwise cleanup deletes the image the printed deployment command needs. The same check covers the settings-block options.
  • Reject a mismatched image while continuing to the existing validated folder fallback, as the PR description and existing packing reference promise. Folder cleanup happens only after the image is accepted.

Both regression tests failed against the original change and pass with these fixes. bundle remains the default. The identity still covers the image's size, header and index, not same-length changes inside file contents; legacy folder extractions carry no image identity until re-extracted as images.

Checked locally:

  • 451 tool tests, with 8 optional skips; all 38 iOS tests; all 63 focused tests after rebasing on the concurrent Absolum update.
  • Host unit tests and the Metal graphics test suite.
  • iOS compile check: 178 files, 0 failed; the production iOS project also builds and links unsigned with synthetic modules, including Swift and resource staging.
  • Actual build_ipa.sh --prepare-xcode runs with synthetic inputs: separate mode writes DM_COPY_ROMFS = NO and the title/version/build resource metadata, and bundle mode removes the slim setting.
  • Lint ratchet: 0 new findings. Added the identity header to the impact map; docs and generated symptom index are updated.

On-device install/startup, the alert's appearance, entitlement preservation by a sideloading tool, and a real large-game slim pack timing remain unverified. No device signing or installation was performed.

Scoped game validation for #478 / #493

The change reaches iOS deployment and startup. The shader chain and game profiles are unchanged. Targeted IPA/Xcode staging, C/Python identity and Foundation startup tests exercise the changed paths; Mac game runs provide supplementary coverage.

The original regress.py check --games invocation selected ANIMAL WELL (empty resources), Wonder (compressed resources), Breath of the Wild and Tears of the Kingdom (large resource sets), and Scarlet (another profile). It completed ANIMAL WELL and Wonder. The remaining cold shader rebuilds were stopped after verifying that the baseline and candidate Mac __TEXT,__text sections for both completed games are byte-for-byte identical. This is the reason for narrowing below five games: the new runtime branch is iOS-only, and no shader translation or Mac game code changes. Breath of the Wild translation started, but it has no runtime result; Tears of the Kingdom and Scarlet are unchecked.

The comparison baseline was e06adb2ab794, candidate worktree snapshot da04270ee2aa. The final integration adds the impact-map row and was rebased over an unrelated Absolum profile/docs update; that update's only shared tool change is a comment in sdk_patches.py.

Game Harness classification FPS, baseline → candidate p99 ms, baseline → candidate Frame reached, baseline → candidate New normalized RED lines
ANIMAL WELL 010020D01AD24000 CHANGED 28.5 → 59.4 38.45 → 16.97 4436 → 5790 0
Super Mario Bros. Wonder 010015100B514000 NEW-FAIL / REGRESSION 25.3 → 20.2 137.66 → 99.59 1613 → 1543 0

This is not a green runtime comparison. ANIMAL WELL's baseline missed screenshots at 68, 72 and 95 seconds; its candidate did not. Wonder missed the route's frame-2400-by-60-seconds target in both revisions, and its candidate also missed screenshots at 50 and 58 seconds. Wonder's baseline log includes repeated display-link stalls. The measured Mac was busy, and baseline/candidate Mac instructions are identical. These results do not isolate a regression caused by this iOS deployment change, and no performance improvement is claimed. The classifications and missing coverage are retained here rather than counted as a pass.

No on-device install/startup, alert appearance, sideloader entitlement preservation or large-game slim pack timing is claimed.

Closing as integrated. Device validation remains a follow-up.

@seedds seedds closed this Oct 28, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…s#493)

Add --romfs separate to unsigned IPA and prepared Xcode builds. Keep the extracted image available for one-time transfer and compare its size and header/index identity before using Documents/romfs.img. Keep bundle as the default and keep add-on content bundled.

Reject separate deployment with extraction cleanup before building, since cleanup otherwise deletes the image the printed push command needs. Reject mismatching images while retaining the existing validated folder fallback; regression tests reproduce both original failures.

Validate 451 tool tests (8 optional skips), 38 iOS tests, the actual prepared-project settings in both modes, 178 iOS compilation units, and the lint ratchet. Game regression and build results are recorded in the PR reply. Device startup and sideloader entitlement preservation are not claimed.

Co-authored-by: v0lumehi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants