#51831: perf: backport startup performance improvements to 42-x-y (#51602, #51697, #51703)
Backport of #51602
Backport of #51697
Backport of #51703
Manual backport of three stacked startup-performance changes to 42-x-y (the same set that landed on 43-x-y via #51792), in a single PR:
- #51602 — perf: push sandboxed renderer startup data via mojo and cache preload bytecode
- #51697 — perf: build-time V8 code cache for the
electron/js2cframework bundles - #51703 — perf: boot the browser process from an embedded Node startup snapshot
All three were originally labeled no-backport; this PR backports them deliberately on request. They are semver/patch (internal performance work, no public API change).
The first commit cherry-picks the squashed 43-x-y backport (ea8b0bb from #51792), which already includes the filenames.auto.gni regeneration and the patch re-contexting. Branch-specific adaptations:
- New V8 patch (
patches/v8/fastapi_store_v8_cfunction_pointer_directly_in.patch):42-x-ypins Chromium 148 / V8 14.8, which stores fast-API CFunction overloads in non-serializableManaged<>objects, sorun_node_mksnapshot(added by #51703) fails withCheckGlobalAndEternalHandles failed. This backports upstream V8 CL 7828135 ("[fastapi] Store v8::CFunction pointer directly in FunctionTemplateInfo", first shipped in V8 15.0.163 — already in43-x-y's pinned V8, hence no patch needed there), which wraps the CFunction in a serializableForeigninstead. The only adaptation from upstream is keeping 14.8'sGetCFunction(Isolate*, int)signature. yarn.lock: theget-intrinsicresolutions pin from #51697 collapses the1.2.1/1.2.4/1.3.0split (this branch had three copies;43-x-yhad two) into a single1.3.0entry; verified canonical withyarn install --mode=update-lockfile(no drift).script/run-clang-tidy.ts: re-resolved without theelectron_smooth_round_rect.ccexclusion, which doesn't exist on this branch.patches/{chromium,node}/.patches: dropped three43-x-y-only entries that the 3-way merge incorrectly carried over.
The two new Chromium patches were pre-validated against Chromium 148.0.7778.218 with this branch's patch stack applied — both apply cleanly.
Notes: Improved app startup performance — the main process now boots from an embedded Node.js startup snapshot, framework bundles and preload scripts are cached as compiled V8 bytecode, and sandboxed renderer startup data is pushed ahead of navigation instead of fetched via blocking IPC. Preload stack traces now show the correct file path and line number.
Backport Information
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