#52872: fix: let custom V8 snapshots reach the main process again
Description of Change
Since the main process started booting from the embedded Node.js startup snapshot (#51703), its context is deserialized from that blob, which is built on top of the stock snapshot_blob.bin at build time. Anything a custom snapshot puts into the default context — electron-mksnapshot users, and the browser_v8_context_snapshot.bin that the loadBrowserProcessSpecificV8Snapshot fuse selects — therefore never showed up in the main process on native-built targets (mac arm64, linux x64, win x64), while cross-built targets, which ship without the Node snapshot, kept working. spec/fixtures/snapshot-items-available reproduces it (ReferenceError: f is not defined), but CI has only been running verify-mksnapshot.py --create-snapshot-only since the GHA migration, so nothing noticed.
This:
- skips the embedded Node snapshot for the main process when the fuse is on or the loaded v8 context snapshot is not the one this build shipped, and bootstraps Node from scratch on the loaded blob as snapshot-less builds do. The check is a size + V8-blob-header comparison against constants that
build/checksum_header.pynow emits next to the existing SHA-256, so there is no hashing at startup; - re-adds the full
verify-mksnapshot.pyrun (create the custom blobs and launch Electron with them) to one native test leg (linux x64); - documents in
fuses.mdthat a custom snapshot means the main process gives up the startup snapshot's boot-time win.
Verified locally on linux x64: verify-mksnapshot.py end-to-end goes from not ok … f is not defined to ok successfully used custom snapshot, and a stock build still boots the main process from the embedded snapshot.
Checklist
- PR description included and stakeholders cc'd
-
npm testpasses - tests are changed or added
- relevant API documentation, tutorials, and examples are updated and follow the documentation style guide
Release Notes
Notes: Fixed custom V8 snapshots (electron-mksnapshot, and the loadBrowserProcessSpecificV8Snapshot fuse) having no effect in the main process on macOS arm64, Linux x64 and Windows x64.
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron