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

chromium: Enable swiftshader by default. #83304

Merged

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented Mar 24, 2020

Motivation for this change

This makes it possible to use chromium headless with WebGL
(e.g. for webdriver tests) without having to rebuild from source.

Also fixes #41918.

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.

CC @bendlas from relevant issues/PRs/commits:

Copy link
Member

@primeos primeos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff LGTM. Could you also test if it works as expected?

pkgs/applications/networking/browsers/chromium/common.nix Outdated Show resolved Hide resolved
@nh2
Copy link
Contributor Author

nh2 commented Mar 24, 2020

Building just completed. The .so files are installed as expected:

Swiftshader files found; installing
'out/Release/swiftshader/libEGL.so' -> '/nix/store/f5jn1ks26absxldpzz571xbvqbvk77w6-chromium-unwrapped-80.0.3987.132/libexec/chromium/swiftshader/libEGL.so'
'out/Release/swiftshader/libGLESv2.so' -> '/nix/store/f5jn1ks26absxldpzz571xbvqbvk77w6-chromium-unwrapped-80.0.3987.132/libexec/chromium/swiftshader/libGLESv2.so'

As expected, the package is slightly larger (5 MB):

$ nix path-info --human-readable -S /nix/store/4fzd30p6mfcmknns20q9qnmgc83psmdx-chromium-80.0.3987.132 /nix/store/b3b9xa5m33800c3hmkn4r9qj2z6j78h7-chromium-80.0.3987.132/bin/chromium
/nix/store/4fzd30p6mfcmknns20q9qnmgc83psmdx-chromium-80.0.3987.132	 635.8M
/nix/store/b3b9xa5m33800c3hmkn4r9qj2z6j78h7-chromium-80.0.3987.132	 640.8M

# ls -lh /nix/store/f5jn1ks26absxldpzz571xbvqbvk77w6-chromium-unwrapped-80.0.3987.132/libexec/chromium/swiftshader/
total 5.1M
-r-xr-xr-x 1 root root 414K Jan  1  1970 libEGL.so
-r-xr-xr-x 1 root root 4.6M Jan  1  1970 libGLESv2.so

Could you also test if it works as expected?

@primeos Yes.

It works:

Launching with /nix/store/b3b9xa5m33800c3hmkn4r9qj2z6j78h7-chromium-80.0.3987.132/bin/chromium --user-data-dir=$HOME/tmp/chromium-testdir --disable-gpu, I get

image

image

and webgl works but is slow (as Swiftshader software rendering is now in effect).

That is in contrast to current NixOS, where --disable-gpu gets us no webgl support at all:

image


I've also checked that it works with full hardware acceleration as usual when --disable-gpu is not given.

This makes it possible to use chromium headless with WebGL
(e.g. for webdriver tests) without having to rebuild from source.

The upstram default is to enable, thus simply removing our disabling switch.

Also fixes NixOS#41918.
@nh2 nh2 force-pushed the issue-41918-chromium-swiftshader-by-default branch from 3b66dd7 to 015bb28 Compare March 24, 2020 21:51
@ofborg ofborg bot requested a review from primeos March 24, 2020 22:01
@nh2
Copy link
Contributor Author

nh2 commented Mar 25, 2020

Ideally I think it would be nice to remove this line to keep it as simple as possible (i.e. we only set values where we differ from the default), but that's optional. The upstream default can be seen here.

I have now also re-built it with that change pushed, still works.

Ready to merge from my side.

Copy link
Member

@primeos primeos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for this enhancement and especially for the testing and detailed post of the results, that helps a lot! ❤️

@primeos primeos merged commit 29becfc into NixOS:master Mar 25, 2020
@nh2
Copy link
Contributor Author

nh2 commented Mar 28, 2020

I've made a tentative backport to 20.03 in #83562.

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

Successfully merging this pull request may close these issues.

chromium: swiftshader broken, enable_swiftshader has no effect
2 participants