Skip to content

perf(lite): ship 22 of the 98 rootfs libraries in the native package - #21

Merged
LYJW131 merged 1 commit into
litefrom
perf/slim-native-rootfs
Nov 3, 2026
Merged

LYJW131 merged 1 commit into
litefrom
perf/slim-native-rootfs

Conversation

@LYJW131

@LYJW131 LYJW131 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

The wrapper-lite-linux-x86_64 package carries every library of rootfs/system/lib64: 98 files, 119 MiB unpacked, 50 MB zipped. Most are Android UI, graphics, audio and media frameworks that the Apple libraries list in DT_NEEDED and a headless service never calls.

tools/slim-rootfs.py runs on the packaged copy in build-lite's "Package native release" step. It keeps the 22 libraries lite loads and removes the other 76. It rewrites seven DT_NEEDED entries (libCoreFoundation, libandroidappmusic x2, libdaapkit, libmedialibrarycore, libmediaplatform, libstoreservicescore) so they name libc.so again; the loader then skips them. It fails the build if a kept library still lists a removed one, or if a kept library is not reachable from lite.

Why at packaging, not in rootfs/. lite links against rootfs/, and the QEMU assets and the Docker image copy it. This change touches only the native package, which is what amdl installs into its guest. The other two keep the whole set until they are checked the same way.

How the set differs from the fpkeyd minimal runtime. It adds libCoreADI.so and drops libc++.so. Nothing imports from libCoreADI, but libCoreFP.so and libstoreservicescore.so find its exports (cvu8io98wun, vdfut768ig) with dlsym. Without it every request fails to build its anisette headers (ADISetProvisioningPath failed: -45075) and /m3u8 and the token refresh fail. No kept library lists libc++.so, and it is never loaded.

Tested on rog against a copy of a logged-in cn account, the old and the slim payload side by side:

  • /status, /token and its background refresh work.
  • /m3u8 and /webplayback return the same URLs, /lyrics the same bytes, /license the same error.
  • /key works for the ALAC, Atmos, AAC-LC and HE-AAC variants of a song.
  • An amdl album download (ALAC, 14 tracks) and one song each in Atmos, AAC, binaural and downmix decode with 0 ffmpeg errors, and their audio streams hash the same as the old payload's.
  • A wrong-credential --login runs the same AuthenticateFlow round trip on both.

The wrapper-lite-linux-x86_64 package carried all 98 libraries of
rootfs/system/lib64 (119 MiB unpacked), most of them Android UI, graphics,
audio and media frameworks that the Apple libraries list in DT_NEEDED and a
headless service never calls. tools/slim-rootfs.py, run on the packaged copy
only, keeps the 22 libraries lite loads and rewrites seven DT_NEEDED entries
(libCoreFoundation, libandroidappmusic, libdaapkit, libmedialibrarycore,
libmediaplatform, libstoreservicescore -> libandroid / libOpenSLES) to name
libc.so again, so the loader skips them.

rootfs/ stays whole: lite links against it, and the QEMU assets and the Docker
image copy it. libCoreADI.so stays although nothing imports from it: libCoreFP
and libstoreservicescore find its exports with dlsym, and without it every
request fails to build its anisette headers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: LYJW131 <153256373+LYJW131@users.noreply.github.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment thread tools/slim-rootfs.py
Comment on lines +154 to +158
freed = 0
for n in removed:
p = os.path.join(lib, n)
freed += os.path.getsize(p)
os.unlink(p)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Existing installations retain 76 obsolete libraries

When an installed manager updates, slim-rootfs.py removes libraries only from the downloaded package. extractZip overwrites existing files without removing them, leaving all 76 obsolete libraries on disk.

Learn more

The manager installs the native artifact by extracting its zip over the existing payload in installWrapperLite. extractZip only creates or overwrites files, so deleting libraries from the new zip cannot remove copies installed by an earlier build. A manager upgrading from the full payload therefore retains the old libraries and their disk usage, even though the new archive contains only 22.

Example: A manager already has 98 files under rootfs/system/lib64. It downloads the new 22-library artifact and extracts it into the same directory; the other 76 files remain there.

Recommended fix: Make the manager's payload upgrade prune obsolete library files after extracting a validated artifact, or atomically replace the rootfs/system subtree while preserving account data under rootfs/data.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

# The package keeps only the libraries wrapper-lite loads. rootfs/
# stays whole: lite links against it, and the QEMU assets and the
# Docker image copy it.
python3 tools/slim-rootfs.py dist-native/rootfs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Slim native artifact lacks runtime coverage

The dependency walk cannot verify runtime symbol lookups. The existing QEMU boot test uses the unslimmed rootfs, so it does not exercise the native artifact.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@LYJW131

LYJW131 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Both points are right and neither blocks the merge.

  1. Stale libraries: an upgraded install keeps the 76 old files on disk, unused (the seven rewritten libraries no longer list them). A fresh install and a new data disk are unaffected. Removing libraries that the new zip lacks belongs in the manager's install, so it comes as its own change with a test, not in this packaging step.
  2. Runtime coverage: the dependency walk cannot see a dlsym. That is how libCoreADI.so was found to be needed; the PR text says so. The slim package was run on rog against the previous package, and amdl's guest boot (TestGuestBoot) installs the pinned payload, so the pin bump to this build is gated by it.

@LYJW131
LYJW131 merged commit 38bebfc into lite Nov 3, 2026
9 checks passed
LYJW131 added a commit to AMDL-Web/apple-music-downloader that referenced this pull request Nov 3, 2026
…s 98 libraries

The payload the guest's manager installs drops from 50.1 MB to 30.6 MB
zipped, and from 119 MiB to 66 MiB unpacked (AMDL-Web/wrapper#21). Run on a
copy of a logged-in account beside the previous payload, it gave the same
/m3u8, /lyrics and /webplayback answers, keys for ALAC, Atmos, AAC-LC and
HE-AAC that decrypt, and album and song downloads whose audio streams hash
the same.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: LYJW131 <153256373+LYJW131@users.noreply.github.com>
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.

1 participant