electron: [Bug]: App launch failed with error- "gpu process launch failed: error_code=40"
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Electron Version
16.0.1, 15.1.2, 14.1.1, 13.1.7, 12.2.1, 11.5.0, 10.4.7,
What operating system are you using?
Windows
Operating System Version
Windows 10 version 10.0.18363 Build 18363
What arch are you using?
x64
Last Known Working Electron version
9.4.4
Expected Behavior
Created a demo electron app with electron version>=10 and generated the exe with electron-builder. When I opened the app, the app should be launched without any error.
Actual Behavior
Created a demo electron app with electron version>=10 and generated the exe with electron-builder. When I opened the app, the app failed to launch with below error,
[2752:1201/155923.159:ERROR:gpu_process_host.cc(962)] GPU process launch failed: error_code=40
[2752:1201/155923.268:ERROR:gpu_process_host.cc(962)] GPU process launch failed: error_code=40
[2752:1201/155923.346:ERROR:gpu_process_host.cc(962)] GPU process launch failed: error_code=40
[2752:1201/155923.424:ERROR:gpu_process_host.cc(962)] GPU process launch failed: error_code=40
[2752:1201/155923.502:ERROR:gpu_process_host.cc(962)] GPU process launch failed: error_code=40
[2752:1201/155923.580:ERROR:gpu_process_host.cc(962)] GPU process launch failed: error_code=40
[2752:1201/155923.659:ERROR:gpu_process_host.cc(962)] GPU process launch failed: error_code=40
[2752:1201/155923.737:ERROR:gpu_process_host.cc(962)] GPU process launch failed: error_code=40
[2752:1201/155923.815:ERROR:gpu_process_host.cc(962)] GPU process launch failed: error_code=40
[2752:1201/155923.815:FATAL:gpu_data_manager_impl_private.cc(417)] GPU process isn't usable. Goodbye.
Though the app didn’t launch, in the taskbar, two processes were running in the background processes.
Testcase Gist URL
No response
Additional Information
System Info:
OS Name : Microsoft Windows 10 Enterprise N
Version: 10.0.18363 Build 18363
Processor: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz, 2601 Mhz, 4 Core(s), 8 Logical Processor(s)
Adapter Type: Intel(R) HD Graphics Family, Intel Corporation compatible
Adapter Description: Intel(R) HD Graphics 530
Here is my source code,
index.js:
const { app, BrowserWindow } = require('electron')
const path = require('path');
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
devTools: true,
}
})
win.loadFile('index.html');
};
app.whenReady().then(() => {
createWindow()
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
});
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
</body>
</html>
package.json:
{
"name": "DemoApp_Ev-16.0.1",
"version": "1.0.0",
"description": "This is for testing launch issue",
"main": "index.js",
"author": "Naimur",
"license": "MIT",
"scripts": {
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"package": "electron-packager ./ --all"
},
"devDependencies": {
"@electron-forge/cli": "^6.0.0-beta.61",
"electron": "^16.0.1",
"electron-builder": "^22.14.5",
"electron-packager": "^15.4.0"
},
"build": {
"appId": "naimur.test.11",
"mac": {
"category": "naimur.test.11"
}
}
}
Workaround:
It works fine, when I open the app with --no-sandbox or --disable-gpu-sandbox.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 7
- Comments: 32 (4 by maintainers)
Commits related to this issue
- Add electron switch `no-sandbox`, addressing https://github.com/electron/electron/issues/32074 — committed to fredrikhr/s-KaiNet-node-sp-auth by fredrikhr 2 years ago
Update: After I stumbled upon many more command switches concerning the GPU in another open Electron bug (#30966), after I added all the ones below, it did actually render again for our users.
I’m not sure which specific one does the trick, however as stated previously, just adding the
app.commandLine.appendSwitch('no-sandbox');switch was not enough.Hope that info helps a little, in conjunction with the crash reports.
Yes, this is still an issue and I found that it is caused by running from a (mapped) network share. When running from a local folder, there is no problem.
Also including the list of app.commandLine stuff from hhhuut above solves it, but also disables a lot of gpu related things which you may not want.
I think there are several different issues being conflated here due to the similar error messages.
error_code=18 is SBOX_ERROR_CREATE_PROCESS and means that CreateProcess itself failed, so yeah it’d be expected that we don’t see any crash dump data from the gpu process - it never started at all. Error 18 can be caused by running an Electron app from some kinds of non-local / mapped network drive. For example, if you try to run an Electron Windows app inside Parallels from a drive mapped to your Mac, you will get this error.
error_code=40 is SBOX_ERROR_CANNOT_SETUP_INTERCEPTION_THUNK which indicates the GPU process started, but the sandbox was unable to complete the setup process. I don’t know what can cause this.
In both cases they indicate something very low level and not necessarily GPU specific has gone wrong.
I have the same problem as you,It works with
--disable-gpu-sandbox, but the Chrome Extensions background page doesn’t workRan into this issue when trying to run in a windows 11 vm on m1 mac running in parallels with both x64 and arm64 electron builds from electron-packager.
Adding
no-sandboxordisable-gpu-sandboxflags allowed the app to run. It worked fine on a regular windows machine(x64) without these flags. It also works fine on macOS without the flags.app.commandLine.appendSwitch('disable-gpu-sandbox')I think
disable-gpu-sandboxwould be preferred tono-sandboxentirely.Edit strike that, only using disable-gpu-sandbox makes it so the dev tools cannot be opened in any way. You need to use
no-sandboxto get the devtools to show.A handful of our customers (all on Win10) report the same problem, the logs look like the following:
Just to put this out there, invisible windows work fine, so they start and load their HTML/JS correctly, however visible windows (such as most application’s main window) gets created correctly but then crashes as soon as you try to load the HTML file.
We upgraded our project from a really old Electron version (8.2.5), so the last working version of ours might not be useful, however I can report that this problem occurs in both, 16.0.7 as well as the latest 17.0.0 (which those logs were generated with).
I’ll try to verify if the
--no-sandboxflag works for those customers as well, and I’ll try to get my hands on a crash dump from them in the near future.