Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoadBrowserProcessSpecificV8Snapshot fuse yields a crashing package #8797

Open
t3chguy opened this issue Jan 22, 2025 · 8 comments
Open

LoadBrowserProcessSpecificV8Snapshot fuse yields a crashing package #8797

t3chguy opened this issue Jan 22, 2025 · 8 comments

Comments

@t3chguy
Copy link
Contributor

t3chguy commented Jan 22, 2025

[0122/170408.987:FATAL:v8_initializer.cc(687)] Error loading V8 startup snapshot file

Digging deeper, LoadBrowserProcessSpecificV8Snapshot wants a browser_v8_context_snapshot.bin but this does not exist in the build

Image

Copying v8_context_snapshot.bin to browser_v8_context_snapshot.bin seems to resolve the issue

@mmaietta
Copy link
Collaborator

Hi there!
Missing some key details here, can you please list the following?
electron-builder version, electron version, and whether you're using elecron/fuses directly or via electronFuses config property.

electron-builder just unpacks an electron release artifact, so my initial guess here is that the browser_v8_context_snapshot file isn't in the release artifact. electron-builder is not supposed to create it AFAIK as electron-builder is a packager, not a bundler.

@charliez0
Copy link

I meet this problem too, all latest version, changing fuses with @elecron/fuses

@mmaietta
Copy link
Collaborator

Pretty sure you're supposed to compile/build/provide your OWN browser snapshot in order to use that fuse as it's specific to your own installed (or forked) electron version.
https://www.electronjs.org/docs/latest/tutorial/fuses#loadbrowserprocessspecificv8snapshot

Copying v8_context_snapshot.bin to browser_v8_context_snapshot.bin seems to resolve the issue

Doing this does nothing different than having LoadBrowserProcessSpecificV8Snapshot: false as all you're doing under-the-hood is forcing electron to load two identical snapshots, versus its default of loading one snapshot for both main and browser.

Overall, this isn't a bug, it's an end-user misconfiguration. Happy to be proven otherwise, but I'm not finding any resources on how to compile a xxxx_snapshot.bin

@t3chguy
Copy link
Contributor Author

t3chguy commented Jan 23, 2025

Doing this does nothing different than having LoadBrowserProcessSpecificV8Snapshot: false as all you're doing under-the-hood is forcing electron to load two identical snapshots, versus its default of loading one snapshot for both main and browser.

The fuses page says separate snapshots can also improve security

Using separate snapshots for renderer processes and the main process can improve security

Which could be construed as a form of scope isolation but agreed the docs are lacking

@t3chguy
Copy link
Contributor Author

t3chguy commented Jan 23, 2025

I think ultimately this issue is about https://www.electron.build/tutorials/adding-electron-fuses.html#loadbrowserprocessspecificv8snapshot not being clear, it looks like something you can just enable

@mmaietta
Copy link
Collaborator

Let me ask the electron HQ folks and get back to you on this. I see a way electron-builder could auto-copy the default snapshot (for the security hardening between main and renderer) while also allowing a user-supplied one to be copied instead. I need to see first if they're okay with that.

@RaisinTen
Copy link

Hi! I did some experiments to speed up Electron app startup time using V8 snapshots in https://github.com/RaisinTen/electron-snapshot-experiment, so y'all might find that useful. If you browse the repo at https://github.com/RaisinTen/electron-snapshot-experiment/tree/a3bf2c070d2aa72bf17720c1e7fdc95970c1a3ca, you can find out more about how to use the LoadBrowserProcessSpecificV8Snapshot fuse.

@mmaietta
Copy link
Collaborator

Here's a snippet of the response from Electron dev chat

So it sounds like, to utilize the fuse, the developer should be providing the browser v8 snapshot themselves? From the electron-builder config side, instead of a boolean property, have it as a filepath string and only if that is provided, copy it and activate the fuse.

Yes, it’s provided by the developer.
And in particular, the developer might provide two snapshots: one for the browser and one for the main process.

What this means is that I'll need to change the property LoadBrowserProcessSpecificV8Snapshot from boolean to be an object of:

loadBrowserProcessSpecificV8Snapshot?: {
	mainProcessSnapshotPath?: string
	browserProcessSnapshotPath: string
}

electron-builder will handle the copying and throw an error if the file can't be found. If the snapshot files are successfully copied, then the fuse is activated. I'll probably also log a warning that mainProcessSnapshotPath should be provided to most efficiently leverage the fuse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants