Remove --always-compact V8 flag: no longer recognized in newer V8

V8's --js-flags parser stops at the first unrecognized flag and silently
drops everything after it in the same string. --always-compact was removed
from V8 at some point after the versions bundled in Electron ~41; on newer
Electron (confirmed broken on a castlabs v43.0.0+wvcus build) it killed
--optimize-for-size right after it in every js-flags string that had it,
even though --optimize-for-size itself is still valid. Verified via
--v8-options against the actual bundled V8 that gc-global/optimize-for-size/
max-semi-space-size/initial-heap-size are still real flags — only
always-compact needed to go.
This commit is contained in:
2026-07-26 04:21:46 -07:00
parent b045a22b5d
commit 0f83d848d1
+3 -3
View File
@@ -92,7 +92,7 @@ export function computeFlags(system: SystemInfo, options: ComputeFlagsOptions =
logger.log(`Setting Pi JS heap size to: ${heap}MB`);
b.addValue(
'js-flags',
`--expose-gc --max-old-space-size=${heap} --gc-global --always-compact --optimize-for-size --max-semi-space-size=1 --initial-heap-size=${Math.floor(heap / 4)}`
`--expose-gc --max-old-space-size=${heap} --gc-global --optimize-for-size --max-semi-space-size=1 --initial-heap-size=${Math.floor(heap / 4)}`
);
}
} else if (gen === 4) {
@@ -104,7 +104,7 @@ export function computeFlags(system: SystemInfo, options: ComputeFlagsOptions =
if (enabled(enable, 'jsHeap')) {
const heap = jsHeapSizeMB ?? (system.totalMemMB < 2048 ? 1024 : system.totalMemMB < 4096 ? 1536 : 2048);
logger.log(`Setting Pi 4 JS heap size to: ${heap}MB`);
b.addValue('js-flags', `--expose-gc --max-old-space-size=${heap} --gc-global --always-compact --optimize-for-size`);
b.addValue('js-flags', `--expose-gc --max-old-space-size=${heap} --gc-global --optimize-for-size`);
}
} else if (gen >= 5) {
b.addValue('enable-features', 'VaapiVideoDecoder,VaapiVideoEncoder')
@@ -172,7 +172,7 @@ export function computeFlags(system: SystemInfo, options: ComputeFlagsOptions =
// a meaningful chunk of the budget, so cap it. Left unset on 'high' — not worth the
// extra minor-GC frequency when memory isn't the constraint.
const semiSpaceFlag = system.memoryTier === 'low' ? ' --max-semi-space-size=2' : system.memoryTier === 'medium' ? ' --max-semi-space-size=4' : '';
b.addValue('js-flags', `--expose-gc --max-old-space-size=${heap} --gc-global --always-compact --optimize-for-size${semiSpaceFlag}`);
b.addValue('js-flags', `--expose-gc --max-old-space-size=${heap} --gc-global --optimize-for-size${semiSpaceFlag}`);
}
if (enabled(enable, 'diskCache')) {