electron icon indicating copy to clipboard operation
electron copied to clipboard

[Bug]: App launch failed with error- "gpu process launch failed: error_code=40"

Open raivekhan opened this issue 4 years ago • 34 comments

Preflight Checklist

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.

raivekhan avatar Dec 01 '21 11:12 raivekhan

I have the same problem as you,It works with --disable-gpu-sandbox, but the Chrome Extensions background page doesn't work

zerooverture avatar Jan 26 '22 09:01 zerooverture

Please attach a crash dump. You can collect them by adding the following snippet to your main process code, before app.whenReady:

const { app, crashReporter } = require('electron')

console.log(app.getPath('crashDumps'))
crashReporter.start({ submitURL: '', uploadToServer: false })

Then reproduce the crash, zip up the crash dumps directory and attach it here.

nornagon avatar Jan 26 '22 22:01 nornagon

Please attach a crash dump. You can collect them by adding the following snippet to your main process code, before app.whenReady:

const { app, crashReporter } = require('electron')

console.log(app.getPath('crashDumps'))
crashReporter.start({ submitURL: '', uploadToServer: false })

Then reproduce the crash, zip up the crash dumps directory and attach it here.

Not changes after attaching your snippet code, kindly provide simple source code so that we can overcome from this issue.

Best Regards

RohitRawat12 avatar Feb 02 '22 19:02 RohitRawat12

@RohitRawat12 my snippet shows you how to collect a crash dump. If you supply the crash dump, I may be able to help further.

nornagon avatar Feb 02 '22 19:02 nornagon

Crashpad.zip electron: 16.0.2 I have similar problem and I use your snippet code get this dump from my user.

shugen002 avatar Feb 08 '22 11:02 shugen002

A handful of our customers (all on Win10) report the same problem, the logs look like the following:

[12836:0208/171448.703:ERROR:gpu_process_host.cc(973)] GPU process launch failed: error_code=18
[12836:0208/171448.703:WARNING:gpu_process_host.cc(1284)] The GPU process has crashed 1 time(s)
[12836:0208/171448.727:ERROR:gpu_process_host.cc(973)] GPU process launch failed: error_code=18
[12836:0208/171448.727:WARNING:gpu_process_host.cc(1284)] The GPU process has crashed 2 time(s)
[12836:0208/171448.740:ERROR:gpu_process_host.cc(973)] GPU process launch failed: error_code=18
[12836:0208/171448.740:WARNING:gpu_process_host.cc(1284)] The GPU process has crashed 3 time(s)
[12836:0208/171448.744:ERROR:gpu_process_host.cc(973)] GPU process launch failed: error_code=18
[12836:0208/171448.744:WARNING:gpu_process_host.cc(1284)] The GPU process has crashed 4 time(s)
[12836:0208/171448.765:ERROR:gpu_process_host.cc(973)] GPU process launch failed: error_code=18
[12836:0208/171448.765:WARNING:gpu_process_host.cc(1284)] The GPU process has crashed 5 time(s)
[12836:0208/171448.777:ERROR:gpu_process_host.cc(973)] GPU process launch failed: error_code=18
[12836:0208/171448.777:WARNING:gpu_process_host.cc(1284)] The GPU process has crashed 6 time(s)
[12836:0208/171448.779:ERROR:gpu_process_host.cc(973)] GPU process launch failed: error_code=18
[12836:0208/171448.779:WARNING:gpu_process_host.cc(1284)] The GPU process has crashed 7 time(s)
[12836:0208/171448.804:ERROR:gpu_process_host.cc(973)] GPU process launch failed: error_code=18
[12836:0208/171448.804:WARNING:gpu_process_host.cc(1284)] The GPU process has crashed 8 time(s)
[12836:0208/171448.813:ERROR:gpu_process_host.cc(973)] GPU process launch failed: error_code=18
[12836:0208/171448.813:WARNING:gpu_process_host.cc(1284)] The GPU process has crashed 9 time(s)
[12836:0208/171448.813:FATAL:gpu_data_manager_impl_private.cc(448)] GPU process isn't usable. Goodbye.

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-sandbox flag works for those customers as well, and I'll try to get my hands on a crash dump from them in the near future.

hhhuut avatar Feb 08 '22 18:02 hhhuut

Update: The --no-sandbox flag did not resolve the problem for our users, the application kept on crashing.

Please find all the crashdumps attached, they are from three different users and each of them provided crashdumps with and without the sandbox flag (if that makes any difference in the dumps at all).

Crashdumps.zip

I hope this issue can be solved quickly since I didn't find any more workarounds we could try.

hhhuut avatar Feb 09 '22 07:02 hhhuut

I was able to get my hands on two more crashdumps. Please find a zip with all the crashdumps (original three and the two new ones) attached.

Crashdumps2.zip

hhhuut avatar Feb 10 '22 09:02 hhhuut

Hi, just started to use electron and it looks like I'm getting into same problem. I'm able to run app with --no-sandbox flag though. Please find a zip with crashdump, hope it helps :)

Crashpad.zip

aleksandrs94 avatar Feb 10 '22 10:02 aleksandrs94

And again new crashdumps from two more of our users. Crashdumps3.zip

hhhuut avatar Feb 16 '22 06:02 hhhuut

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.

app.commandLine.appendSwitch('no-sandbox');
app.commandLine.appendSwitch('disable-gpu');
app.commandLine.appendSwitch('disable-software-rasterizer');
app.commandLine.appendSwitch('disable-gpu-compositing');
app.commandLine.appendSwitch('disable-gpu-rasterization');
app.commandLine.appendSwitch('disable-gpu-sandbox');
app.commandLine.appendSwitch('--no-sandbox');
app.disableHardwareAcceleration();

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.

hhhuut avatar Feb 17 '22 13:02 hhhuut

I found that the problem was not hardware, I reinstalled a clean version of the OS(Windows 10 pro 19041) from a running computer. It reappeared problem

zerooverture avatar Feb 21 '22 06:02 zerooverture

Bump: Has there been any progress on evaluating this particular problem and the crashreports?

hhhuut avatar Mar 10 '22 15:03 hhhuut

@nornagon any progress ? or any more specify information we need to collect from our client ?

shugen002 avatar Mar 15 '22 03:03 shugen002

Ran 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-sandbox or disable-gpu-sandbox flags 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-sandbox would be preferred to no-sandbox entirely.

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-sandbox to get the devtools to show.

epelc avatar Jun 14 '22 19:06 epelc

This is a problem in Luban too. --disable-gpu-sandbox helps there.

HorstBaerbel avatar Sep 18 '22 15:09 HorstBaerbel

Unfortunately the crash dump data doesn't seem to include crashes from the GPU process, so something must be going quite wrong!

Perhaps you could collect GPU info from chrome://gpu/? run npx electron chrome://gpu/ or load the same page in Chrome, and attach the resulting data here.

nornagon avatar Oct 27 '22 18:10 nornagon

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.

mikehearn avatar Nov 02 '22 10:11 mikehearn

Any update are their?

dohooo avatar Nov 21 '22 12:11 dohooo

FYI @ https://oofhours.com/2023/02/02/samsung-magician-wont-launch-heres-a-simple-fix/

war59312 avatar Feb 03 '23 19:02 war59312

I ran into this issue when experimenting with16.2.8 and BoxedApp Packer (to make it a portable, single EXE on Windows). The "no-sandbox" CLI flag also resolved it in that case as well.

FWIW, packaging to a "portable" app with electron-builder instead didn't have the issue in my tests, but I haven't yet tested the portable in an actual VM to see if it has the problem.

kiddailey avatar Feb 07 '23 04:02 kiddailey

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

github-actions[bot] avatar May 09 '23 01:05 github-actions[bot]

Still an issue - I'm new to electron, but the initial setup you get when running npm init electron-app@latest my-app -- --template=webpack-typescript already does not work at all. Keeps crashing with these GPU errors.

I'm on Windows 11 with WSL

uncaught avatar May 20 '23 10:05 uncaught

have the same err in windows11

jbeetle avatar May 31 '23 10:05 jbeetle

I have a similar error in Arch Linux kernel version 6.4.7-arch1-1:

[1185259:0818/070037.216495:ERROR:zygote_communication_linux.cc(291)] Failed to send GetTerminationStatus message to zygote
[1185259:0818/070037.219115:ERROR:gpu_process_host.cc(985)] GPU process launch failed: error_code=1002
...
[1185259:0818/070037.219442:FATAL:gpu_data_manager_impl_private.cc(440)] GPU process isn't usable. Goodbye.

Where are these error codes defined? This may give clues on what's going on.

YourGirlInSpace avatar Aug 18 '23 14:08 YourGirlInSpace

I experienced a similar error when the executable is placed on a network folder (a UNC path).

in my case app.commandLine.appendSwitch('disable-gpu-sandbox'); solved the error, but this is undesireble because this may cause a security risk.

I am pretty sure that the error is related to chromium https://chromium.googlesource.com/chromium/chromium/+/master/content/public/common/content_switches.cc#118

ej-toita avatar Aug 25 '23 02:08 ej-toita

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.

HasseM avatar Sep 23 '23 12:09 HasseM

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

I still have the following error on the latest version 28.1.0 electron, when the module is placed on a UNC path on Windows.

[32140:1227/123812.304:ERROR:gpu_process_host.cc(987)] GPU process launch failed: error_code=18
[32140:1227/123812.360:ERROR:gpu_process_host.cc(987)] GPU process launch failed: error_code=18
[32140:1227/123812.380:ERROR:gpu_process_host.cc(987)] GPU process launch failed: error_code=18
[32140:1227/123812.402:ERROR:gpu_process_host.cc(987)] GPU process launch failed: error_code=18
[32140:1227/123812.421:ERROR:gpu_process_host.cc(987)] GPU process launch failed: error_code=18
[32140:1227/123812.440:ERROR:gpu_process_host.cc(987)] GPU process launch failed: error_code=18
[32140:1227/123812.460:ERROR:gpu_process_host.cc(987)] GPU process launch failed: error_code=18
[32140:1227/123812.478:ERROR:gpu_process_host.cc(987)] GPU process launch failed: error_code=18
[32140:1227/123812.498:ERROR:gpu_process_host.cc(987)] GPU process launch failed: error_code=18
[32140:1227/123812.498:FATAL:gpu_data_manager_impl_private.cc(448)] GPU process isn't usable. Goodbye.

ej-toita avatar Dec 27 '23 03:12 ej-toita

Just adding my 2 cents here, had the same problem using windows 10 and WSL 2.0.

Running the project from bash installed on windows instead of WSL, worked.

As mentioned by @HasseM

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.

IaveL avatar Dec 28 '23 00:12 IaveL