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

--enable-features flags not passed into Electron #526

Closed
takase1121 opened this issue Apr 20, 2024 · 5 comments
Closed

--enable-features flags not passed into Electron #526

takase1121 opened this issue Apr 20, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@takase1121
Copy link
Contributor

takase1121 commented Apr 20, 2024

Describe the bug

I am trying to get VAAPI Video Decoding to work on amdgpu, which needs a bunch of flags and some amount of prayers.
Since Vesktop tries to append it's own enable-features flags this caused it to override the previous (user added) flags. I have no proof of this happening, but in my testing removing this line made it work:

app.commandLine.appendSwitch("enable-features", "VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiVideoDecoder");

Those flags has good intentions, but it will take more flags (to force Electron to use ANGLE and ANGLE to use Vulkan) to make it work, and it's not possible to set them if it got overridden by the flags above.

To Reproduce

Not working

  1. Install vesktop-git from AUR.
  2. run vesktop --use-gl=angle --use-angle=vulkan --ignore-gpu-blocklist --enable-gpu-rasterization --enable-zero-copy --enable-features=Vulkan,VulkanFromANGLE,DefaultANGLEVulkan,VaapiIgnoreDriverChecks,VaapiVideoDecoder,PlatformHEVCDecoderSupport,UseMultiPlaneFormatForHardwareVideo
  3. womp womp womp womp

Making it work

  1. clone Vesktop, remove the line in
    app.commandLine.appendSwitch("enable-features", "VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiVideoDecoder");
  2. pnpm i && pnpm build
  3. electron29 --use-gl=angle --use-angle=vulkan --ignore-gpu-blocklist --enable-gpu-rasterization --enable-zero-copy --enable-features=Vulkan,VulkanFromANGLE,DefaultANGLEVulkan,VaapiIgnoreDriverChecks,VaapiVideoDecoder,PlatformHEVCDecoderSupport,UseMultiPlaneFormatForHardwareVideo .
  4. Electron tries to use GPU to decode (good effort but still terrible)

Expected behavior

Vesktop can detect if --enable-features is set, get all the flags and append its own flags. After that, Vesktop will append it back to app.cmdLine.

Screenshots

Working
image

Not Working
image

Desktop (please complete the following information):

  • OS/Distro: Arch Linux
  • Desktop Environment (linux only): KDE Plasma 6.0.4 X11 Session
  • Version: Linux 6.8.7-2-cachyos

Command line output

Not working:

[takase@nijika Vesktop]$ vesktop --use-gl=angle --use-angle=vulkan --ignore-gpu-blocklist --enable-hagpu-rasterization --enable-zero-copy --enable-features=Vulkan,VulkanFromANGLE,DefaultANGLEVulkan,VaapiIgnoreDriverChecks,VaapiVideoDecoder,PlatformHEVCDecoderSupport,UseMultiPlaneFormatatForHardwareVideo .
[34770:0420/222341.067069:ERROR:gl_surface_egl.cc(430)] eglCreateWindowSurface failed with error EGL_BAD_CONFIG
[34770:0420/222341.068479:ERROR:gl_surface_egl.cc(430)] eglCreateWindowSurface failed with error EGL_BAD_CONFIG

Working:

[takase@nijika Vesktop]$ electron29 --use-gl=angle --use-angle=vulkan --ignore-gpu-blocklist --enable-hagpu-rasterization --enable-zero-copy --enable-features=Vulkan,VulkanFromANGLE,DefaultANGLEVulkan,VaapiIgnoreDriverChecks,VaapiVideoDecoder,PlatformHEVCDecoderSupport,UseMultiPlaneFormatForHardwareVideo .
[32876:0420/214736.951896:ERROR:gl_utils.cc(424)] [.RendererMainThread-0xf0001a54e00]GL DriverMessage (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
[32876:0420/214736.955938:ERROR:gl_utils.cc(424)] [.RendererMainThread-0xf0001a54e00]GL DriverMessage (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
[32876:0420/214736.960205:ERROR:gl_utils.cc(424)] [.RendererMainThread-0xf0001a54e00]GL DriverMessage (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
[32876:0420/214739.618146:ERROR:gl_utils.cc(424)] [.RendererMainThread-0xf0001a54e00]GL DriverMessage (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels (this message will no longer repeat)
[32876:0420/222323.142360:ERROR:angle_vulkan_image_backing.cc(653)] Importing textures with external sampling into GL is not possible
[32876:0420/222323.142536:ERROR:shared_image_manager.cc(228)] SharedImageManager::ProduceSkia:Trying to produce a Skia representation from an incompatible backing: AngleVulkanImageBacking
[32876:0420/222323.142866:ERROR:gl_utils.cc(420)] [.RendererMainThread-0xf0001a54e00] GL_INVALID_VALUE: unknown source image mailbox.

Additional context

At this point I am not even sure if Electron is using GPU acceleration. It's barely using any VRAM and all the stuff is stored in GTT (RAM). Testing with powertop does give me a 2W decrease in power consumption, so I'll take it.

For reference:

  1. PR to support hardware video decoding in amdgpu: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26165#note_2367572
  2. Command to enable it in Chromium/Electron: https://bbs.archlinux.org/viewtopic.php?id=244031&p=40
@takase1121 takase1121 added the bug Something isn't working label Apr 20, 2024
@Vendicated
Copy link
Member

you should figure out which of these flags are necessary for it to work and open a pr that adds them to the source code. this way it can benefit everyone

@takase1121
Copy link
Contributor Author

In my testing, all the flags I placed there is necessary, but it will have to know if the driver is amdgpu (because the whole ANGLE Vulkan dance is only needed (probably for now) for AMD only). Besides, this is using mesa-git and not generally available which is why I'm not comfortable with adding it to Vesktop yet.

I'm suggesting a way to passthrough enable-feature flags to Vesktop. I believe that Vesktop is doing great with the flags, but if the user tries to pass something to Electron, Vesktop should not override it. Maybe detecting if enable-features is present will be a better solution (assuming that Chromium actually only take the last enable-feature flags).

@takase1121
Copy link
Contributor Author

Yep, confirmed that the last switch will override all previous switches: https://source.chromium.org/chromium/chromium/src/+/main:base/command_line.h;l=9;drc=515737a1eff38ecfffef07d7dbf5717742cab958

@libjared
Copy link

As for your proposal to add that long list of flags to Vesktop, on my machine, it prints that the settings for angle/vulkan are not an allowed combination.
AMD Arch KDE Wayland electron29.
Just my 2c of unsolicited feedback.

@takase1121
Copy link
Contributor Author

As for your proposal to add that long list of flags to Vesktop, on my machine, it prints that the settings for angle/vulkan are not an allowed combination. AMD Arch KDE Wayland electron29. Just my 2c of unsolicited feedback.

  1. You need mesa-git, specifically 24.1-devel
  2. Wayland is currently out of the question, you need to at least run it in XWayland, sorry
  3. You need to use system Electron.
  4. Make sure you have a Vulkan driver installed.

Now you get the idea why these flags must not be added to Vesktop for now. They're highly experienmental and one wrong move will disable GPU acceleration completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants