fix(mods): lower per-icon size limit from 8 MiB to 512 KiB - #152
Conversation
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
Pixnop
left a comment
There was a problem hiding this comment.
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.
|
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
left a comment
There was a problem hiding this comment.
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.
MAX_MOD_IMAGE_BYTESwas 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: typicalmodicon.pngfiles weigh tens of kilobytes.What changed
src/ipc/adapters/modScan.ts: reduceMAX_MOD_IMAGE_BYTESfrom8 * 1024 * 1024to512 * 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 typecheckpassesnpm run lint:cipassesnpm run test:coveragepasses (1110 tests)iconCache.test.tssuite validates eviction logic at various budgetsFixes #146