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

firefox: wrapper: add libva to libs #81917

Merged
merged 2 commits into from May 5, 2020
Merged

Conversation

@colemickens
Copy link
Contributor

colemickens commented Mar 6, 2020

Motivation for this change

This change allows VA-API to work in Firefox Nightly builds as provided by nixpkgs-mozilla.

Two changes:

  • add libva to the Firefox wrapper
  • move to ffmpeg_4 (without it, (firefox/ffmpeg) doesn't attempt to use libva/vaapi)
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • 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 nixpkgs-review --run "nixpkgs-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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
@colemickens
Copy link
Contributor Author

colemickens commented Mar 8, 2020

Followup:

@colemickens
Copy link
Contributor Author

colemickens commented Mar 9, 2020

Looks like it's probably related to this:

[Child 23304: MediaPDecoder #1]: D/PlatformDecoderModule Initialising FFmpeg decoder.
[Child 23304: MediaPlayback #1]: D/PlatformDecoderModule Sandbox decoder rejects requested type
[Child 23304: MediaPDecoder #3]: D/PlatformDecoderModule Initialising VA-API FFmpeg decoder
[Child 23304: MediaPDecoder #3]: D/PlatformDecoderModule VA-API FFmpeg is disabled by platform
[Child 23304: MediaPDecoder #3]: D/PlatformDecoderModule Initialising FFmpeg decoder.
[Child 23304: MediaPlayback #1]: D/PlatformDecoderModule Sandbox decoder rejects requested type
[Child 23304: MediaPlayback #1]: D/PlatformDecoderModule Sandbox decoder rejects requested type
[Child 23304: MediaPlayback #1]: D/PlatformDecoderModule Sandbox decoder rejects requested type
[Child 23304: MediaPlayback #1]: D/PlatformDecoderModule Sandbox decoder rejects requested type
[Child 23304: MediaPDecoder #2]: D/PlatformDecoderModule Initialising FFmpeg decoder.
[Child 23304: MediaPDecoder #4]: D/PlatformDecoderModule Initialising VA-API FFmpeg decoder
[Child 23304: MediaPDecoder #4]: D/PlatformDecoderModule VA-API FFmpeg is disabled by platform
[Child 23304: MediaPDecoder #4]: D/PlatformDecoderModule Initialising FFmpeg decoder.
[Child 23304: MediaPDecoder #1]: D/PlatformDecoderModule FFmpeg init successful.
WebGL creation failed: 
* Refused to create WebGL2 context because of blacklist entry: FEATURE_FAILURE_GLXTEST_FAILED

GLXtest process failed (exited with status 1): No visuals found
@colemickens
Copy link
Contributor Author

colemickens commented Mar 9, 2020

cc: @worldofpeace You replied in another thread about Firefox and hardware acceleration in NixOS. I am using the nightly package (a bin package).

@primeos
Copy link
Member

primeos commented Apr 23, 2020

@colemickens since Firefox 75 is released now and 76 should already be in the beta channel you might want to give this another shot, if you have time. If not feel free to simply ignore this comment ;)

It would also be also nice if we had VA-API support for the firefox package that we build from source, but that seems outside the scope of this PR (and Firefox rebuilds most likely take a very long time).

@colemickens
Copy link
Contributor Author

colemickens commented Apr 27, 2020

Oops. In one version of this I had actually built firefox as well. Anyway, this works with Nightly!

[Child 29119: MediaPlayback #1]: D/PlatformDecoderModule Sandbox decoder rejects requested type
[Child 29119: MediaPlayback #1]: D/PlatformDecoderModule Sandbox decoder rejects requested type
[Child 29119: MediaPDecoder #1]: D/PlatformDecoderModule Initialising VA-API FFmpeg decoder
[Child 29119: MediaPDecoder #2]: D/PlatformDecoderModule Initialising FFmpeg decoder.
libva info: VA-API version 1.6.0
libva info: Trying to open /run/opengl-driver/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0

[h264 @ 0x7f4fe222e000] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x7f4fe222e000] nal_unit_type: 8(PPS), nal_ref_idc: 3
[Child 29119: MediaPDecoder #2]: D/PlatformDecoderModule VA-API FFmpeg init successful
[h264 @ 0x7f4fe222e000] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x7f4fe222e000] nal_unit_type: 5(IDR), nal_ref_idc: 3
[Child 29119: MediaPDecoder #2]: D/PlatformDecoderModule Choosing FFmpeg pixel format for VA-API video decoding.
[Child 29119: MediaPDecoder #2]: D/PlatformDecoderModule Requesting pixel format VAAPI_VLD
[h264 @ 0x7f4fe222e000] Format vaapi_vld chosen by get_format().
[h264 @ 0x7f4fe222e000] Format vaapi_vld requires hwaccel initialisation.
[h264 @ 0x7f4fe222e000] Considering format 0x3231564e -> nv12.
[h264 @ 0x7f4fe222e000] Picked nv12 (0x3231564e) as best match for yuv420p.

We can merge? In the meantime I can try to make the change for firefox from source too.

@colemickens colemickens marked this pull request as ready for review Apr 27, 2020
@colemickens
Copy link
Contributor Author

colemickens commented Apr 27, 2020

Ah, I should be careful, I actually have some other related firefox commits on the branch that I tested from. Let me do a few additional checks around nightly and/or wait for this build to finish.

@colemickens
Copy link
Contributor Author

colemickens commented Apr 27, 2020

Interesting, it looks like this does require moving over to ffmpeg4!

without this, adding libva is insufficient to get VA-API working in
Firefox.
@colemickens
Copy link
Contributor Author

colemickens commented Apr 27, 2020

This time I'm sure I'm testing firefox-nightly with the wrapper from this branch:

export MOZ_LOG="PlatformDecoderModule:5"; \
 set f (~/code/nixcfg/nixbuild.sh -A latest.firefox-nightly-bin); \
$f/bin/firefox --no-remote -P vaapi &> /tmp/firefox

similar logs as I posted ~1 hr ago, with two commits now, pushing now.

@colemickens colemickens force-pushed the colemickens:nixpkgs-firefox-libva branch from c960df8 to 552d729 Apr 27, 2020
@colemickens
Copy link
Contributor Author

colemickens commented Apr 27, 2020

Note, I don't know if this is a strong requirement by Firefox or is due to how we build ffmpeg4? But I definitely couldn't get this working with nightly without adding the ffmpeg4 commit.

@ofborg ofborg bot requested review from andir and edolstra Apr 27, 2020
@colemickens
Copy link
Contributor Author

colemickens commented Apr 28, 2020

Alright, I'm going to put a couple more hours in and then give up and back out the change to the source package and leave this as a change only targetting nightly. However, I know a lot of people want the source build to have va-api too.

@colemickens colemickens force-pushed the colemickens:nixpkgs-firefox-libva branch from 915cb09 to 552d729 Apr 29, 2020
@colemickens
Copy link
Contributor Author

colemickens commented Apr 29, 2020

Okay, back to the original scope of this PR. I'll iterate on this, but I know this helps Nightly users, so let's go with this.

I can confirm both commits are needed. The older ffmpeg in the wrapper does NOT work, it doesn't even attempt to use va-api or libva.

Fortunately, this also means it's easy for Nightly users to test, since this only requires a change to the wrapper and won't need to rebuild Firefox.

@primeos
primeos approved these changes May 4, 2020
Copy link
Member

primeos left a comment

LGTM :) But I'll leave the final decision and merging up to @andir since he's the maintainer.

@andir
Copy link
Member

andir commented May 5, 2020

Can I test this with the firefox-{beta,bin} from nixpkgs or will that not work?

With firefox-bin on master it didn't really work yet:

EDIT

firefox-beta did work.. I'll merge this in. Thank you for looking at this @colemickens!

@andir andir merged commit d9f4f06 into NixOS:master May 5, 2020
14 checks passed
14 checks passed
Evaluation Performance Report Evaluator Performance Report
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="552d729"; rev="552d72957193ebd6051e9bf5ddeaa0c1ed59f96e"; } ./pkgs/t
Details
grahamcofborg-eval-lib-tests nix-build --arg pkgs import ./. {} ./lib/tests/release.nix
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="552d729"; rev="552d72957193ebd6051e9bf5ddeaa0c1ed59f96e"; } ./nixos/
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="552d729"; rev="552d72957193ebd6051e9bf5ddeaa0c1ed59f96e"; } ./nixos/
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="552d729"; rev="552d72957193ebd6051e9bf5ddeaa0c1ed59f96e"; } ./nixos/
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="552d729"; rev="552d72957193ebd6051e9bf5ddeaa0c1ed59f96e"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="552d729"; rev="552d72957193ebd6051e9bf5ddeaa0c1ed59f96e"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="552d729"; rev="552d72957193ebd6051e9bf5ddeaa0c1ed59f96e"; } ./pkgs/t
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
@nixos-discourse
Copy link

nixos-discourse commented Jul 4, 2020

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/hardware-acceleration-on-firefox/7947/6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.