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

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

Open
3 tasks done
raivekhan opened this issue Dec 1, 2021 · 37 comments
Open
3 tasks done
Labels

Comments

@raivekhan
Copy link

raivekhan commented Dec 1, 2021

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.

@zerooverture
Copy link

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

@nornagon
Copy link
Member

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.

@RohitRawat12
Copy link

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

@nornagon
Copy link
Member

nornagon commented Feb 2, 2022

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

@shugen002
Copy link

shugen002 commented Feb 8, 2022

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

@hhhuut
Copy link

hhhuut commented Feb 8, 2022

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
Copy link

hhhuut commented Feb 9, 2022

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
Copy link

hhhuut commented Feb 10, 2022

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

@aleksandrs94
Copy link

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

@hhhuut
Copy link

hhhuut commented Feb 16, 2022

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

@hhhuut
Copy link

hhhuut commented Feb 17, 2022

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.

@zerooverture
Copy link

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

@hhhuut
Copy link

hhhuut commented Mar 10, 2022

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

@shugen002
Copy link

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

@epelc
Copy link

epelc commented Jun 14, 2022

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.

@kiddailey
Copy link

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.

@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2023

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 github-actions bot added the stale label May 9, 2023
@uncaught
Copy link

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

@github-actions github-actions bot removed the stale label May 21, 2023
@jbeetle
Copy link

jbeetle commented May 31, 2023

have the same err in windows11

@YourGirlInSpace
Copy link

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.

@ej-toita
Copy link

ej-toita commented Aug 25, 2023

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

@HasseM
Copy link

HasseM commented Sep 23, 2023

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.

@electron-issue-triage
Copy link

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!

@ej-toita
Copy link

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.

@IaveL
Copy link

IaveL commented Dec 28, 2023

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.

@electron-issue-triage
Copy link

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!

@wusticality
Copy link

bump

@Hrxn
Copy link

Hrxn commented May 11, 2024

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.

To clarify:

It also does not work when running from a mapped network drive? Not a UNC path, a real mapped drive?

@arthurgailes
Copy link

Same issue here, and yes, only from mapped drive. Same drive unmapped works fine, using portable mode.

@anonhostpi
Copy link

@electron-issue-triage
Copy link

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!

@joao-fcastro
Copy link

bump

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

No branches or pull requests