-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
chromium (72): Add hardware video decoding using VAAPI #56973
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
Conversation
- Introduces a VAAPISupport parameter to the expression (default to false) - Import patches from the Arch package - Enable use_vaapi gn parameter - Put libva.so in dlopen seach path by tweaking LD_LIBRARY_PATH env var in the launcher script.
This supersedes #56794 where I messed up the git history. I can confirm that videos are indeed decoded through libva, both with the i965 and iHD. Checked in chromium logs, chrome://media-internals and gpu-top. Instead of explicitly setting LD_LIBRARY_PATH to expose the lib, I'd much prefer using the ''runtimeDependencies'' mechanism that modifies the binary rpath. I guess some post-build hooks should be set up. I'll look into it. @colemickens @hyperfekt @yorickvP |
@@ -143,6 +145,11 @@ let | |||
# ++ optional (versionRange "68" "72") ( githubPatch "<patch>" "0000000000000000000000000000000000000000000000000000000000000000" ) | |||
] ++ optionals (!stdenv.cc.isClang && (versionRange "71" "72")) [ | |||
( githubPatch "65be571f6ac2f7942b4df9e50b24da517f829eec" "1sqv0aba0mpdi4x4f21zdkxz2cf8ji55ffgbfcr88c5gcg0qn2jh" ) | |||
] ++ optionals (VAAPISupport && (versionRange "72" "73")) [ | |||
./patches/enable-vaapi-72.patch | |||
./patches/vaapi-relax-the-version-check-for-VA-API-72.patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if there's any reason to include the libva version relaxations, they're already in the tree anyway (just a matter of time until the patches don't apply), and it shouldn't be a problem, right? (this comment applies to both of the VA_CHECK patches)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are they in the tree ? What release will they be included in ? I haven't really checked chromium history log tbh.
My thinking was to only apply those to 72.xx as 73 should barely need any patching. I think versionRange is non-inclusive in its upper range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just meant, since we're on NixOS and we know compile time and runtime libva will match, we can save ourselves all of the headache and ignore these 2 VA_CHECK patches. In the short-term, they don't matter to us, in the longer-term, they will be upstream anyway.
Otherwise, I think everything is in chromium upstream (maybe not in any release yet) except the "enable-mojo" patch (and it's my understanding that Chromium isn't interested in taking that patch upstream). I can dig up the links to upstream commits if you're curious for the use_vaapi patch and the 2 VA_CHECK patches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To put it another way, if all three channels build with this and these patches still apply, then I think it's fine you have it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
] ++ optionals (VAAPISupport && (versionRange "72" "73")) [ | ||
./patches/enable-vaapi-72.patch | ||
./patches/vaapi-relax-the-version-check-for-VA-API-72.patch | ||
./patches/enable-mojo-video-decoders-by-default-72.patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other patches should be applied to versions > 72, not clamped to 73.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that 73 wont need those patches. Am I in the wrong ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought so, and may have said so, but I think @hyperfekt pointed out that the patch to enable-by-default and add the disable-hw-accel flag is still needed. After looking more, I agree with that conclusion and have been having success including it for all builds (dev/beta/stable) on my branch.
AFAIK, and from trying to look for these commits upstream, for 73+, only the "enable-mojo-video-..." patch will be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -261,6 +268,8 @@ let | |||
} // optionalAttrs pulseSupport { | |||
use_pulseaudio = true; | |||
link_pulseaudio = true; | |||
} // optionalAttrs (VAAPISupport && (versionRange "72" "73")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, shouldn't version clamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -92,6 +93,9 @@ in stdenv.mkDerivation { | |||
buildCommand = let | |||
browserBinary = "${chromium.browser}/libexec/chromium/chromium"; | |||
getWrapperFlags = plugin: "$(< \"${plugin}/nix-support/wrapper-flags\")"; | |||
libPath = stdenv.lib.makeLibraryPath ( | |||
versionAtLeast version "72" && stdenv.lib.optional VAAPISupport libva |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have an assert that VAAPISupport
is only allowed true
when version is > 72 instead? It seems weird to let the user specify VAAPISupport and then ignore it everywhere by &&
with a version check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be cleaner indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Fix wrapper creation when putting libva in dlopen search path.
BTW, I think we might replace the LD_LIBRARY_PATH dance by adding 'autoPatchelfHook' to the build inputs and 'libva' to 'runtimeDependencies' |
There has been some thought on that problem .. IIRC @aszlig wants to create I'm thinking towards including ccache into the compilation (maybe similar to the existing distcc stdenv). One way or the other (or even another), it's not quite trivial ... |
I tried running this build, and it works, but I couldn't determine vaapi status, because my NVIDIA GPU doesn't support it. Is vdpau support on your radar as well? |
…unds only once Don't patch libva version check relaxation in, as it is a controlled and known quantity in nix. Also, simplify chromium version check by using a unique assertion instead of checking it everytime.
@bendlas Thanks for the infos regarding incremental compilation. I'll look into it. @colemickens is the current state of the PR what you have in mind ? Could you check if it works ok with the non-stable channels ? I dont have the cpu power to build them in a reasonable time. |
@@ -13,8 +13,11 @@ | |||
, cupsSupport ? true | |||
, pulseSupport ? config.pulseaudio or stdenv.isLinux | |||
, commandLineArgs ? "" | |||
, VAAPISupport ? false, libva ? null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I maintain we would want to enable this by default in versions >72, otherwise almost noone would be able to use it given the extremely long compile times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinion on that. Would create an alias (something like "chromium-vaapi") force the builders to cache a binary ?
Another solution would be to condition it on libva presence in hardware.opengl.extraPackages
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a separate alias would cause Hydra to build Chromium twice - probably not something we want, as the evaluations already take long enough.
AFAIK it's not possible (and shouldn't be) to incorporate NixOS config values in Nix packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a separate alias would cause Hydra to build Chromium twice - probably not something we want, as the evaluations already take long enough.
Maybe. Anyway, I guess this decision is the package maintainers to make. @bendlas ?
AFAIK it's not possible (and shouldn't be) to incorporate NixOS config values in Nix packages.
Indeed, I looked at it from a nixos centric pov. You're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with enabling by default on master. I'd leave it disabled by default on 19.03 (for now).
@bendlas AFAIK, the VDPAU-VAAPI-translation is somewhat buggy, which is why it isn't generally included. |
@@ -143,6 +145,9 @@ let | |||
# ++ optional (versionRange "68" "72") ( githubPatch "<patch>" "0000000000000000000000000000000000000000000000000000000000000000" ) | |||
] ++ optionals (!stdenv.cc.isClang && (versionRange "71" "72")) [ | |||
( githubPatch "65be571f6ac2f7942b4df9e50b24da517f829eec" "1sqv0aba0mpdi4x4f21zdkxz2cf8ji55ffgbfcr88c5gcg0qn2jh" ) | |||
] ++ optionals VAAPISupport [ | |||
./patches/enable-vaapi-72.patch | |||
./patches/enable-mojo-video-decoders-by-default-72.patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chromium 73 was released to stable yesterday, so we should be able to drop the ./patches/enable-mojo-video-decoders-by-default-72.patch
needed only for 72 and require version 73 for enabled VAAPI support (default.nix:L81), as I imagine the number of people who need specifically 72 with VAAPI support should be negligible.
Also enable-vaapi-72.patch
is not 72-specific, so you might want to remove that version number from the name?
There's also still a bunch of patch files in this PR that aren't actually used.
Motivation for this change
Using HW video decoding should improve performances and "smoothness" while reducing battery consumption.
Seems to be an often requested feature per issue #21481
Things done
Introduces a VAAPISupport parameter to the expression (default to false)
Import patches from the Arch package
Enable use_vaapi gn parameter
Put libva.so in dlopen seach path by tweaking LD_LIBRARY_PATH env var in the launcher script.
Tested using sandboxing (nix.useSandbox on NixOS, or option
sandbox
innix.conf
on non-NixOS)Built on platform(s)
Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
Tested compilation of all pkgs that depend on this change using
nix-shell -p nox --run "nox-review wip"
Tested execution of all binary files (usually in
./result/bin/
)Determined the impact on package closure size (by running
nix path-info -S
before and after)Assured whether relevant documentation is up to date
Fits CONTRIBUTING.md.