NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.33k stars 13.57k forks source link

Discord renders a black window on Wayland #159267

Open Baughn opened 2 years ago

Baughn commented 2 years ago

Describe the bug

If you start the standalone (Electron-based) Discord client on Wayland, though possibly only Wayland-on-Nvidia, it renders an entirely black window.

This is not nixos-specific. Various workarounds are posted around the internet; the ones that work best are to run it with --disable-gpu, or (preferrably) --use-gl=desktop. I don't know what implications would come of making the second one the default.

Steps To Reproduce

Steps to reproduce the behavior:

  1. nix run nixpkgs#discord

Expected behavior

The discord window should render. ;-)

Screenshots

image image

Notify maintainers

@ldesgoui @MP2E @devins2518

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.16-lqx2, NixOS, 22.05 (Quokka)`
 - multi-user?: `yes`
 - sandbox: `relaxed`
 - version: `nix-env (Nix) 2.6.0`
 - channels(svein): `""`
 - nixpkgs: `/etc/nixpkgs`
SKyletoft commented 2 years ago

It renders fine if you disable hardware acceleration in settings first (obviously done on Xorg)

Baughn commented 2 years ago

For anyone who just wants it to work, here's a workaround you can put in your environment.systemPackages:

    # Work around #159267
    (pkgs.writeShellApplication {
      name = "discord";
      text = "${pkgs.discord}/bin/discord --use-gl=desktop";
    })
    (pkgs.makeDesktopItem {
      name = "discord";
      exec = "discord";
      desktopName = "Discord";
    })

Remove any existing 'discord' entry, of course.

PowersPope commented 2 years ago

Hey @Baughn , where do you write this work around? My discord is black screen as well and passing --use-gl=desktop in the terminal works. However, I don't want to have to do that every time. I am relatively new to Linux, I feel like there is no environment.systemPackages file. So I'm lost exactly where to put this work around! Thanks!

Edit: Built an executable file to just do it for me. Though still curious where you are talking about.

prusnak commented 2 years ago

Electron 17.3.1 with the upstream fix has been released. I guess we need to wait until Discord upgrades their Electron version.

VAWVAW commented 2 years ago

discord --use-gl=desktop only works because it runs on xorg using xwayland.

Baughn commented 2 years ago

Hey @Baughn , where do you write this work around? My discord is black screen as well and passing --use-gl=desktop in the terminal works. However, I don't want to have to do that every time. I am relatively new to Linux, I feel like there is no environment.systemPackages file. So I'm lost exactly where to put this work around! Thanks!

Edit: Built an executable file to just do it for me. Though still curious where you are talking about.

My comment was only relevant on NixOS, where it’s part of the system configuration file.

You sound like you’re just using Nix. In that case, home-manager does something similar.

SuperSamus commented 1 year ago

Discord recently updated its Electron version. Does the issue still persist?

christ776 commented 1 year ago

I can still reproduce it on Discord 0.0.21, Kubuntu 22.10. KDE 5.26

not-matthias commented 1 year ago

This also started happening for me when I started using nvidia drivers.

mrjones2014 commented 1 year ago

For anyone who just wants it to work, here's a workaround you can put in your environment.systemPackages:

    # Work around #159267
    (pkgs.writeShellApplication {
      name = "discord";
      text = "${pkgs.discord}/bin/discord --use-gl=desktop";
    })
    (pkgs.makeDesktopItem {
      name = "discord";
      exec = "discord";
      desktopName = "Discord";
    })

Remove any existing 'discord' entry, of course.

@Baughn This works for me but GNOME doesn't have an icon for Discord, any idea why or how to fix?

mrjones2014 commented 1 year ago

I solved it by downloading the icon locally and adding icon = ./discord.png

CobaltCause commented 1 year ago

Why does --use-gl=desktop do anything at all? It looks like this is supposed to be the default: https://source.chromium.org/chromium/chromium/src/+/main:ui/gl/gl_switches.cc;l=100-101;drc=8bca1335dc7993df8e44307816092f9f9d25d4aa

(Also FWIW, Discord works perfectly fine for me on amdgpu and i915 when started normally (with and without NIXOS_OZONE_WL=1 set) but env -u NIXOS_OZONE_WL Discord --use-gl=desktop is required on the proprietary nvidia drivers.)

JanotLeLapin commented 1 year ago

I solved it by downloading the icon locally and adding icon = ./discord.png

You can also directly reference the icon from your GTK icon theme, here's how I did it using Tela circle:

packages = [
  tela-circle-icon-theme
  (pkgs.makeDesktopItem {
    name = "discord";
    exec = "${pkgs.discord}/bin/discord --use-gl=desktop";
    desktopName = "Discord";
    icon = "${pkgs.tela-circle-icon-theme}/share/icons/Tela-circle/scalable/apps/discord.svg";
  })
];

This setup is probably better as you won't need to manually download the icon so this will make your system reproducible. The location of the icon file might differ depending on your icon theme though.

Ilirski commented 1 year ago

This graphical issue and other chromium / electron based applications graphical issues are probably related to #224332.

Baughn commented 1 year ago

I can confirm that setting NIXOS_OZONE_WL=1 fixes the issue for me. How come that isn't the default?

CobaltCause commented 1 year ago

Because it also breaks other things, for example:

drakon64 commented 9 months ago

I've found that discord --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-features=WaylandWindowDecorations also works on Wayland

nixos-discourse commented 2 months ago

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

https://discourse.nixos.org/t/all-nividia-drivers-crash-or-do-not-work/47427/4

nixos-discourse commented 2 months ago

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

https://discourse.nixos.org/t/all-nividia-drivers-crash-or-do-not-work/47427/6