FreeTubeApp / FreeTube

An Open Source YouTube app for privacy
https://freetubeapp.io/
GNU Affero General Public License v3.0
13.37k stars 825 forks source link

[Bug]: Hardware video acceleration via VA-API does not work #5437

Closed xsmile closed 3 months ago

xsmile commented 3 months ago

Guidelines

Describe the bug

Hardware video acceleration via VA-API on Chromium/Electron often requires additional patches but it has been working well recently.

With https://github.com/FreeTubeApp/FreeTube/commit/d2f14b072a1fadf81ce49a7516bda2bfd7ce3860 freetube started enforcing a parameter to enable it Linux. Currently this breaks video acceleration as a different set of parameters is required to enable VA-API and it is impossible to disable the hardcoded VaapiVideoDecodeLinuxGL setting.

freetube should not hardcode these settings. They should be handled by Electron or left to the user as the parameters can vary depending on the video driver and display server.

Reproduction steps with the AMDGPU driver on X11:

Expected Behavior

A hardware accelerated video decoder is used. The video decoder name shows VaapiVideoDecoder.

Issue Labels

feature stopped working

FreeTube Version

v0.21.1 Beta

Operating System Version

Arch Linux

Installation Method

AUR (Unofficial) - package freetube, which depends on the system package electron31.

Primary API used

Local API

Last Known Working FreeTube Version (If Any)

No response

Additional Information

Hardware video acceleration works when directly using the official electron31 package on Arch Linux: electron31 --enable-features=Vulkan,VulkanFromANGLE,DefaultANGLEVulkan,VaapiIgnoreDriverChecks https://youtu.be/LXb3EKWsInQ.

Nightly Build

efb4f5ff-1298-471a-8973-3d47447115dc commented 3 months ago

@Revival8697 any ideas?

Revival8697 commented 3 months ago

@Revival8697 any ideas?

Author has a point. Currently, FreeTube is forcing VA-API though OpenGL. Author is trying to do the Vulkan way which is not compatible.

Possible solutions for this:

xsmile commented 3 months ago

In my case acceleration via OpenGL doesn't work and I can only the the Vulkan API.

Another issue with the current approach is that the switch enable-features is a list of comma separated values, which can only be set once. freetube overrides it and features enabled by the system electron package or by other means are discarded. E.g. --enable-features=Vulkan,VulkanFromANGLE,DefaultANGLEVulkan,VaapiIgnoreDriverChecks --enable-features=VaapiVideoDecodeLinuxGL will only enable the VaapiVideoDecodeLinuxGL feature.

absidue commented 3 months ago

Just to be clear, the AUR packages are unofficial and not maintained by the FreeTube team. Using any Electron build/runtime other than the one that is bundled in the official FreeTube releases, isn't something we officially support. The AUR packages specifically have a history of using the latest version of Electron, without doing any testing, resulting in it crashing on launch for those users.

That being said one potential fix for your specific use case would be for FreeTube to only set enable-features, if it wasn't already set (I haven't looked into how we would implement that, but it should be possible).

xsmile commented 3 months ago

I created a PR for this. The default behavior remains unchanged - if freetube is launched without custom feature flags, then VaapiVideoDecodeLinuxGL is set.

Revival8697 commented 1 week ago

I created a PR for this. The default behavior remains unchanged - if freetube is launched without custom feature flags, then VaapiVideoDecodeLinuxGL is set.

So I recently bought an AMD device and it only works with Vulkan... I wonder if there is a better way to do this.