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.CommandLine.AppendSwitch does not seem to be working propertly #830

Open
Yuvix25 opened this issue Feb 2, 2024 · 4 comments
Labels

Comments

@Yuvix25
Copy link
Contributor

Yuvix25 commented Feb 2, 2024

  • Version: Electron.NET API 23.6.1, Electron.NET CLI 23.6.1.0
  • .NET Core Version 6.0
  • Node.js v18.12.1
  • Target: Windows

I'm building an app which is using a window with transparent background. While I did get it to work (thanks to #748 ), some users are seeing a black background instead of the transparent one. After doing some research, I stumbled upon this, so I tried adding the following flags:

Electron.App.CommandLine.AppendSwitch("disable-gpu-compositing");
Electron.App.CommandLine.AppendSwitch("disable-gpu");
Electron.App.CommandLine.AppendSwitch("disable-software-rasterizer");

However, when loading the chrome://gpu page to see that these arguments were applied, it appeared that wasn't the case:
image
I then tried manually adding the flags (electronize start /args --disable-gpu-compositing --disable-gpu --disable-software-rasterizer), which gave me this result:
image

So either I'm adding the Electron.App.CommandLine.AppendSwitchs wrong, or they do not work.
You can find the full source code of how I'm adding them here (note that you will only find the disable-gpu-compositing flag there, I added the rest locally without pushing yet)

If there is indeed a bug, is there any way I can get around this to force these arguments to always be passed?

Edit:

When manually adding the appendSwitchs to the main.js file in ElectronNET.Host, they do work. I also made sure that the append switch message sent from Electron.NET is received in Electron.js, so I guess the issue has something to do with the time of appending the switches. I also tried appending them right at the start of the Configure method - with no success.
This worked:

diff --git a/src/ElectronNET.Host/main.js b/src/ElectronNET.Host/main.js
index 0e4079c..179e0d9 100644
--- a/src/ElectronNET.Host/main.js
+++ b/src/ElectronNET.Host/main.js
@@ -26,6 +26,11 @@ if (app.commandLine.hasSwitch('watch')) {
   watchable = true;
 }

+app.commandLine.appendSwitch('enable-transparent-visuals');
+app.commandLine.appendSwitch('disable-gpu');
+app.commandLine.appendSwitch('disable-gpu-compositing');
+app.commandLine.appendSwitch('disable-software-rasterizer');
+
 let currentBinPath = path.join(__dirname.replace('app.asar', ''), 'bin');
 let manifestJsonFilePath = path.join(currentBinPath, manifestJsonFileName);
@ezorzin
Copy link

ezorzin commented Apr 12, 2024

Hi, I have a similar problem. I cannot run webgpu through electron on Linux apparently because I cannot set the "--enable-unsafe-webgpu" and the "--enable-vulkan" flags. As in my comments of the issue I linked to this discussion, it looks like they are not in the list of flags supported by the app.commandLine.appendSwitch method of electron.

Any idea how to fix this? I got no solution from that issue, actually they closed it without a satisfactory answer.
I also tried on Discord: same thing.

Thanks

@FlorianRappl
Copy link
Collaborator

Hi @ezorzin I would love to help you on this one, but unfortunately this seems to have to do with Electron directly and not the Electron.NET wrapper (which has a more general problem with the append switch; nothing to do with the WebGPU).

@SemanticStudios
Copy link

@FlorianRappl
I am having a similar issue (need to run WebGL shader code on VM but lack GPU so I need to set ignore-gpu-blacklist switch).
Would you accept a pull request to try to address this issue? And if so, how long do you think it would take you guys to review and merge? Anything that I could do to make it easier on you?
Asking humbly as I know you guys are busy and supporting open source can be thankless..

@FlorianRappl
Copy link
Collaborator

@SemanticStudios PRs are always welcome - I can have a look quite fast and if reasonable we can surely make a release.

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

4 participants