MagicMirrorOrg / MagicMirror

MagicMirror² is an open source modular smart mirror platform. With a growing list of installable modules, the MagicMirror² allows you to convert your hallway or bathroom mirror into your personal assistant.
http://magicmirror.builders
MIT License
19.7k stars 4.2k forks source link

disable/enable gpu when running under electron #3226

Closed BKeyport closed 1 week ago

BKeyport commented 12 months ago

Does anyone know what this is about, and how to fix it?

[28358:1008/184025.188520:ERROR:object_proxy.cc(590)] Failed to call method: org.freedesktop.portal.Settings.Read: object_path= /org/freedesktop/portal/desktop: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.portal.Desktop was not provided by any .service files

-- while we're at it, can we modify base code to start up with the mesa-loader error disabled?

Thanks!

sdetweil commented 12 months ago

for the mesa loader thing add

export ELECTRON_DISABLE_GPU=1

in from of the npm start if you use my install script, that's

~/MagicMirror/installers/mm.sh

the other error is an assumption on electrons part that there is a desktop control file there but it doesn't.exist on most of our systems anymore. nothing we can do about it

BKeyport commented 12 months ago

I'm aware how to fix it after using your installer - I'm suggesting we come up with some way to proactively disable it.

As for the other one, good to know it's something not able to be fixed. Darn assumptions...

khassel commented 12 months ago

this is coded here

I introduced this with the defensive approach, I'm open to doing it the other way around (e.g. with a new env var ELECTRON_ENABLE_GPU).

Opinions @sdetweil @rejas

sdetweil commented 9 months ago

@khassel I'm ok with enable_gpu most wouldn't need it anyhow.

jalibu commented 8 months ago

Modules with CSS transition animations (like stock tickers) still need it. Some MMM-Jast users report choppy rendering since 2.26.0

I would welcome a more user-friendly way to activate this option. Not all users know how to customize the startup commands and how to set ENV variables.

What about introducing .env files for configuration?

khassel commented 8 months ago

What about introducing .env files for configuration?

AFAIS this is built-in with nodejs version v20.6.0, electron is still on v18 so we would need an extra npm package for this (e.g. dotenv).

Beside this we have only 3 env vars: ELECTRON_DISABLE_GPU, MM_CONFIG_FILE, MM_PORT and the 2 last one are for running 2 mm instances from the same mm dir so it makes no sense to put them in an .env file.

So as long as we are talking about 1 variable I would prefer to add another line in package.json

        "scripts": {
                "start": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js",
                "start:gpu": "ELECTRON_ENABLE_GPU=1 DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js",
                "start:dev": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js dev",

so users could start mm with npm run start:gpu if they need the gpu stuff. But maybe there are better ideas ...

KristjanESPERANTO commented 8 months ago

So as long as we are talking about 1 variable I would prefer to add another line in package.json

I like this idea :slightly_smiling_face: I just have a small change suggestion to avoid redundancy:

    "start:gpu": "ELECTRON_ENABLE_GPU=1 && npm run start",
sdetweil commented 8 months ago

this && won't work on windows. it's not a supported platform but we give instructions for it

KristjanESPERANTO commented 8 months ago

this && won't work on windows. it's not a supported platform but we give instructions for it

Does ELECTRON_ENABLE_GPU=1 (or export ELECTRON_ENABLE_GPU=1) work on Windows? If not I see no problem in using && here.

In the Windows part of the documentation we could add how to set the variable. It think it should be like this:

khassel commented 8 months ago

this works:

"start:gpu": "ELECTRON_ENABLE_GPU=1 npm start",
khassel commented 8 months ago

@jalibu is the above solution o.k. for you?

jalibu commented 8 months ago

@khassel to be honest, I did not really understand this issue with the GPU. Does it occur with everyone who uses a Raspi with Bullseye? Is it an annoying warning or is it an error?

I'm asking because unfortunately, I don't have an MM myself at the moment and have never seen the problem.

Regardless of whether we opt-in or opt-out, I think the solution is ok. It would be great if we had a selection option in the installer scripts @sdetweil

sdetweil commented 8 months ago

@jalibu what would be the prompt for the user. 90% are installing mm for the first time, and don't know what a GPU is, or if they might use it. I am 7 years into using mm and not sure myself.

codac commented 3 months ago

@khassel Regarding Node_Version: 18.17.0 and YARN_Version 1.22.19 when starting up the docker I get the following message in the protocol: ELECTRON_ENABLE_GPU: undefined followed by 'VERSIONS: electron: undefined; used node: 20.14.0; installed node: 20.14.0; npm: 10.7.0; pm2: ' with parameter ELECTRON_DISABLE_GPU = 1

How to fix that protocol message?

sdetweil commented 3 months ago

we changed the GPU setting to OFF by default. so the env string is ELECTRON_ENABLE_GPU =1

codac commented 3 months ago

I have removed the "ELECTRON_DISABLE_GPU = 1" parameter (as you said its default now, but the protocol messages remain the same.

sdetweil commented 3 months ago

correct, you have to add

export ELECTRON_ENABLE_GPU=1

notice the output says enable

sdetweil commented 3 months ago

the docker deployment doesn't use electron so it doesn't matter