Skip to content

fix(mods): lower per-icon size limit from 8 MiB to 512 KiB - #152

Merged
Zaldaryon merged 2 commits into
devfrom
fix/icon-cache-per-icon-limit
Aug 18, 2026
Merged

fix(mods): lower per-icon size limit from 8 MiB to 512 KiB#152
Zaldaryon merged 2 commits into
devfrom
fix/icon-cache-per-icon-limit

Conversation

@Zaldaryon

Copy link
Copy Markdown
Collaborator

MAX_MOD_IMAGE_BYTES was 8 MiB. The total cache budget is 64 MiB, so eight icons at the maximum legal size filled the entire cache by themselves. No real mod icon is anywhere near 8 MiB: typical modicon.png files weigh tens of kilobytes.

What changed

src/ipc/adapters/modScan.ts: reduce MAX_MOD_IMAGE_BYTES from 8 * 1024 * 1024 to 512 * 1024.

Any PNG above 512 KiB is not a reasonable icon. This keeps the cache budget meaningful: 128 maximum-size icons fit now instead of 8.

What was tested

  • npm run typecheck passes
  • npm run lint:ci passes
  • npm run test:coverage passes (1110 tests)
  • The existing iconCache.test.ts suite validates eviction logic at various budgets

Fixes #146

MAX_MOD_IMAGE_BYTES was 8 MiB. The total cache budget is 64 MiB, so
eight icons at the maximum legal size filled the entire cache by
themselves. No real mod icon is anywhere near 8 MiB: typical modicon.png
files weigh tens of kilobytes.

Drop the threshold to 512 KiB. Any PNG above that is not a reasonable
icon. This keeps the cache budget meaningful: 128 maximum-size icons fit
now instead of 8.

Fixes #146
@Zaldaryon
Zaldaryon requested a review from Pixnop August 18, 2026 18:49

@Pixnop Pixnop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The limit itself is right, 8 MiB was indefensible next to a 64 MiB budget, but the one-liner changes more than the body says. declaredSizeAllowed failing for the icon calls settle with ok false, which fails the whole archive: the mod lands in scan.errors as a broken mod, not as a mod without a picture. That was survivable at 8 MiB because nothing real ever hit it; at 512 KiB it becomes reachable, a mod shipping an artful 600 KiB modicon.png goes from listed-with-icon to listed-as-error the day this merges. The file already states the right philosophy two lines below, on the unreadable-icon branch: an icon problem costs the mod its picture, never its place in the list. The size check should follow the same rule, skip the icon and advance instead of settling the archive, and then 512 KiB is a fine number, or even a tighter one. That change also wants one test: a mod with an oversized declared icon appears in mods without an icon rather than in errors, which fails today and passes after.

Also worth carrying in the same commit: the fixture comment at build-fixtures.ts:293 names the 8 MiB figure, and oversized-declared-icon.zip's premise shifts from 'pathological size' to 'merely big', so the comment should say which behavior the fixture now pins.

…the size cap

An oversized modicon.png now costs the mod its picture, not its place in
the list. The limit drops from 8 MiB to 512 KiB (a reasonable ceiling for
a mod icon), and both the declared-size guard and the runtime-size callback
advance past the icon entry instead of settling the archive as an error.

Tests updated: the oversized-declared-icon fixture now expects a successful
read with icon undefined, and the domain-level test asserts the mod lands
in mods without an icon rather than in errors.
@Zaldaryon

Copy link
Copy Markdown
Collaborator Author

Reworked in dcf39c0. The oversized-icon path now advances past the entry (skips the icon) instead of settling the archive as an error. Both the declared-size guard and the runtime-size callback use advance(). A mod shipping a 600 KiB modicon.png appears in the list without a picture instead of being flagged as broken. Test and fixture comment updated to match the new behavior and the 512 KiB figure.

@Pixnop Pixnop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving. The degradation now matches the philosophy the file already stated: an oversized icon costs the mod its picture, never its place. Mutation-verified rather than read: putting a settle back in place of the first advance fails the new oversized-icon test on exactly the right assertion, so the behavior is genuinely pinned, and the fixture comment now names the real cap. With the mod no longer condemned, 512 KiB is a sound number.

@Zaldaryon
Zaldaryon merged commit 811657b into dev Aug 18, 2026
7 checks passed
@Zaldaryon
Zaldaryon deleted the fix/icon-cache-per-icon-limit branch August 18, 2026 19:52
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