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

electron app.disableHardwareAcceleration() #2831

Closed
khassel opened this issue Mar 28, 2022 · 4 comments
Closed

electron app.disableHardwareAcceleration() #2831

khassel opened this issue Mar 28, 2022 · 4 comments

Comments

@khassel
Copy link
Collaborator

khassel commented Mar 28, 2022

Electron is throwing gpu errors under some circumstances e.g. running in a docker container as mentioned here and there were already some threads in the forum about this.

To disable these errors you can add app.disableHardwareAcceleration() in electron.js or --disable-gpu in package.json.

Both variants are ugly because for automating this you can only use sed or similar tools.

So I would like to add an environment variable ELECTRON_DISABLE_GPU and add app.disableHardwareAcceleration() in electron.js only when set.

More info's to disableHardwareAcceleration:

May it is also an option to run always with app.disableHardwareAcceleration()?

@shin10
Copy link
Contributor

shin10 commented Mar 29, 2022

Have you considered to use

electronSwitches: ["disable-gpu"],

in your config.js?

I feel your sed pain, since I have several hardware components attached to GPIO but am developing in WSL mostly. So I have to en/disable the components depending on the platform. To do this I'm running a make recipe which substitutes via envsubst variables sourced from an .env file before starting the app. That's ok-ish I guess. At least I can handle all my secrets that way, too.
It's work in progress but you can have a look at my conf here.

Anyway, I'm super new to MM so if this is a stupid idea, just ignore it. I'm open to suggestions as well.

@khassel
Copy link
Collaborator Author

khassel commented Mar 29, 2022

electronSwitches: ["disable-gpu"],

yes, tested this with no success, --disable-gpu is missing in the list of supported command line switches.

I'm already using the envsubst construction in the docker entrypoint script but thats no solution for this problem.

@shin10
Copy link
Contributor

shin10 commented Mar 29, 2022

Ah, I see. Well, it's been a while, but I once used software rendering for tests of pages with three.js in docker. Back then I used Chrome with OSMesa. There seems to be a similar approach for electron with SwiftShader https://medium.com/@mohamedmansour/how-to-run-electron-js-in-software-rendering-headless-49601b87961e
Maybe that's an alternative to disabling the GPU.

@khassel
Copy link
Collaborator Author

khassel commented Mar 29, 2022

I think the approach with the env var is much simpler than adding the SwiftShader hack.

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

2 participants