fix: let custom V8 snapshots reach the main process again - #52872
Conversation
Since the main process started booting from the embedded Node.js startup snapshot (#51703), its context is deserialized from that blob, which was built on top of the stock snapshot_blob.bin at build time. Objects a custom snapshot puts into the default context -- electron-mksnapshot users, and the browser_v8_context_snapshot.bin the loadBrowserProcessSpecificV8Snapshot fuse selects -- therefore never showed up in the main process on native builds (mac arm64, linux x64, win x64), while cross-built targets, which ship without the Node snapshot, kept working. spec/fixtures/snapshot-items-available ("f is not defined") reproduces it, but CI only ran verify-mksnapshot.py with --create-snapshot-only since the GHA migration. Skip 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 bootstrap 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.py now emits next to the existing SHA-256, so it costs nothing at startup. Re-add the full verify-mksnapshot.py run to one native test leg (linux x64).
|
Release Notes Persisted
|
|
I was unable to backport this PR to "43-x-y" cleanly; |
|
I was unable to backport this PR to "42-x-y" cleanly; |
|
I was unable to backport this PR to "44-x-y" cleanly; |
|
@MarshallOfSound has manually backported this PR to "42-x-y", please check out #52876 |
|
@MarshallOfSound has manually backported this PR to "43-x-y", please check out #52877 |
|
@MarshallOfSound has manually backported this PR to "44-x-y", please check out #52878 |
…52876) fix: let custom V8 snapshots reach the main process again (#52872) Since the main process started booting from the embedded Node.js startup snapshot (#51703), its context is deserialized from that blob, which was built on top of the stock snapshot_blob.bin at build time. Objects a custom snapshot puts into the default context -- electron-mksnapshot users, and the browser_v8_context_snapshot.bin the loadBrowserProcessSpecificV8Snapshot fuse selects -- therefore never showed up in the main process on native builds (mac arm64, linux x64, win x64), while cross-built targets, which ship without the Node snapshot, kept working. spec/fixtures/snapshot-items-available ("f is not defined") reproduces it, but CI only ran verify-mksnapshot.py with --create-snapshot-only since the GHA migration. Skip 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 bootstrap 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.py now emits next to the existing SHA-256, so it costs nothing at startup. Re-add the full verify-mksnapshot.py run to one native test leg (linux x64). (cherry picked from commit 11b7555)
…52877) fix: let custom V8 snapshots reach the main process again (#52872) Since the main process started booting from the embedded Node.js startup snapshot (#51703), its context is deserialized from that blob, which was built on top of the stock snapshot_blob.bin at build time. Objects a custom snapshot puts into the default context -- electron-mksnapshot users, and the browser_v8_context_snapshot.bin the loadBrowserProcessSpecificV8Snapshot fuse selects -- therefore never showed up in the main process on native builds (mac arm64, linux x64, win x64), while cross-built targets, which ship without the Node snapshot, kept working. spec/fixtures/snapshot-items-available ("f is not defined") reproduces it, but CI only ran verify-mksnapshot.py with --create-snapshot-only since the GHA migration. Skip 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 bootstrap 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.py now emits next to the existing SHA-256, so it costs nothing at startup. Re-add the full verify-mksnapshot.py run to one native test leg (linux x64). (cherry picked from commit 11b7555)
…52878) fix: let custom V8 snapshots reach the main process again (#52872) Since the main process started booting from the embedded Node.js startup snapshot (#51703), its context is deserialized from that blob, which was built on top of the stock snapshot_blob.bin at build time. Objects a custom snapshot puts into the default context -- electron-mksnapshot users, and the browser_v8_context_snapshot.bin the loadBrowserProcessSpecificV8Snapshot fuse selects -- therefore never showed up in the main process on native builds (mac arm64, linux x64, win x64), while cross-built targets, which ship without the Node snapshot, kept working. spec/fixtures/snapshot-items-available ("f is not defined") reproduces it, but CI only ran verify-mksnapshot.py with --create-snapshot-only since the GHA migration. Skip 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 bootstrap 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.py now emits next to the existing SHA-256, so it costs nothing at startup. Re-add the full verify-mksnapshot.py run to one native test leg (linux x64). (cherry picked from commit 11b7555)
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.binat build time. Anything a custom snapshot puts into the default context —electron-mksnapshotusers, and thebrowser_v8_context_snapshot.binthat theloadBrowserProcessSpecificV8Snapshotfuse 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-availablereproduces it (ReferenceError: f is not defined), but CI has only been runningverify-mksnapshot.py --create-snapshot-onlysince the GHA migration, so nothing noticed.This:
build/checksum_header.pynow emits next to the existing SHA-256, so there is no hashing at startup;verify-mksnapshot.pyrun (create the custom blobs and launch Electron with them) to one native test leg (linux x64);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.pyend-to-end goes fromnot ok … f is not definedtook successfully used custom snapshot, and a stock build still boots the main process from the embedded snapshot.Checklist
npm testpassesRelease Notes
Notes: Fixed custom V8 snapshots (
electron-mksnapshot, and theloadBrowserProcessSpecificV8Snapshotfuse) having no effect in the main process on macOS arm64, Linux x64 and Windows x64.